+ 5

Performance Testing In C

Is there an easy-to-use function to do simple performance tests here on Sololearn? I read that time() isn't precise enough for that...

17th Apr 2019, 5:34 PM
HonFu
HonFu - avatar
4 Antworten
+ 4
ChillPill , did you have a code here for timing functions?
18th Apr 2019, 7:31 AM
Sonic
Sonic - avatar
+ 3
I found this which check the time taken for a function #include <time.h> clock_t start, end; double cpu_time_used; start = clock(); ... /* Do the work. */ end = clock(); cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
17th Apr 2019, 7:52 PM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 2
*AsterisK*, clock, like time, seems to only return seconds but not milliseconds. I wonder if there's anything else...
17th Apr 2019, 7:55 PM
HonFu
HonFu - avatar
+ 2
HonFu I tested with 4 methods(except time()), sadly none worked here🤔 and FYI: clock doesn't return seconds but somehow SL servers behave that way…
18th Apr 2019, 10:51 PM
Emoji FanBoy
Emoji FanBoy - avatar