use gprof to profile/optimize my C code

The gprof tool is a built-in GNU profiler for generating function call and time usage reports.
It can be installed by apt install binutils in a Ubuntu22.04 Virtual Machine(VM).
I use the VM to profile and optimize my C code in github /review_siftr2_log.

It helped identify two major performance improvements: Commit 011fdc7 and Commit 4d63892.

result examples

By using my Macbook Pro chip Apple M1 Pro, the performance improvement (-20.5% execution time) can be shown as follows.

version

program execution time (seconds)

before the two commits

5.384 (base)

after the two commits

4.281 (-20.5%)

% ./review_siftr2_log -f n1fbsd.cubic.siftr2 -s 863143062;
input file name: n1fbsd.cubic.siftr2
siftr version: 2.0
flow id list:
 id: 863143062 (192.168.50.37:54321<->192.168.50.89:5201) mss:1448 SACK:1 snd/rcv_scal:12/12 cnt:6095526

starting_time: 1731689425.397768
ending_time: 1731689526.176446
log duration: 100.78 seconds
input flow id is: 863143062
plot_file_name: plot_863143062.txt
input file has total lines: 6095528, fragment_cnt == 31
++++++++++++++++++++++++++++++ summary ++++++++++++++++++++++++++++
  192.168.50.37:54321->192.168.50.89:5201 flowid: 863143062
    has 6095526 useful records (5359949 outputs, 735577 inputs)

this program execution time: 5.384 seconds

% ./review_siftr2_log -f n1fbsd.cubic.siftr2 -s 863143062
input file name: n1fbsd.cubic.siftr2
siftr version: 2.0
flow id list:
 id: 863143062 (192.168.50.37:54321<->192.168.50.89:5201) mss:1448 SACK:1 snd/rcv_scal:12/12 cnt:6095526

starting_time: 1731689425.397768
ending_time: 1731689526.176446
log duration: 100.78 seconds
input flow id is: 863143062
plot_file_name: plot_863143062.txt
++++++++++++++++++++++++++++++ summary ++++++++++++++++++++++++++++
  192.168.50.37:54321->192.168.50.89:5201 flowid: 863143062
input file has total lines: 6095528
input flow data_pkt_cnt: 5357264, fragment_cnt: 31, fragment_ratio: 0.000
    has 6095526 useful records (5359949 outputs, 735577 inputs)

this program execution time: 4.281 seconds

chengcui/use_gprof (last edited 2024-11-20T20:52:33+0000 by chengcui)