linux gcc 4.4.1 C99
I am wondering what is the best way to test C program performance.
I have some functions that I have implemented. However, I could use a different design for each function.
Basically, I need to check which design gives the best performance.
Many thanks,
You can use gprof, which is a free profiler.
Take a look at this post on code profilers.
, .
? ! , , .
, " "? , :
0,1 - , , , , , . ( 0,1 , 0,08, .. 80 .)
1 - , , . , 0,1, 1,0 , , "" .
10 - , . , , , . , .
, , . - , RAM, / , , , , , , . , ; . - ( ), , , - " , ?"
, , , valgrind (--tool=callgrind --dump-instr=yes) kcachegrind.
--tool=callgrind --dump-instr=yes
kcachegrind
. , , . Shark Mac OS X gprof Linux.
clock() getrusage(), , :
clock_t t = clock(); for (i = 0; i < 1000; ++i) my_func(); printf("time = %lf\n", (double)(clock() - t) / CLOCKS_PER_SEC);
Profiler , , . Calling clock()/getrusage() (), / .
, , . , .
, , - , .
CPU wallclock-, .
In addition to profiling, you need to run the test code from the harness (driver) to average the readings. Thus, your comparisons are not distorted by a single reading, so you have a large sample with average and standard deviation for comparison. There are many multi-threaded frameworks that can provide load loading.
Source: https://habr.com/ru/post/1726857/More articles:commercial flv player with rtmp - flvSaving and editing JSON on iPhone / iPod - jsonMaven - Runtime Search Dependencies - javaКросс-платформенная платформа для мобильных устройств, которая может обращаться к журналам вызовов - androidhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1726856/c-set-window-behind-desktop-icons&usg=ALkJrhip9hi83UKF6cqZYF0tKfyTRJxMcAHow can a Java virtual machine work on a system without virtualization support? - jvmWeb2Py working directory - pythonCan you reload the JBoss ESB services through an MBean or something similar? - javaWhat good ruby idioms for breaking a large class into modules? - ruby | fooobar.comIn Gtk, when is it better to use Glade / GtkBuilder than native code? - gtkAll Articles