I want to get the execution time of a program that I build and specifically the the time needed to load the data, the execution, for some operations etc. and of course the total any example code or direction where to see. I found something related for research purpose that the programer use MACROS before the and after like #define COUNT__TIME_BEGIN
#define COUNT__TIME_END
and in the MACROS declaration use gettimeofday();
function is this right?
Asked
Active
Viewed 80 times
0

Paulo Gasol
- 83
- 1
- 4
-
2`gettimeofday` produces microsecond resolution. It's what I _used_ to use. Nowadays, I use `clock_gettime(CLOCK_REALTIME,...)`. It gives nanosecond resolution. Under linux [at least], it's low overhead because it's a `vdso` [fast] syscall. Or, with extra effort, on `x86`, you could use `rdtsc` but you have to determine the CPU frequency [to convert ticks to seconds] and that can be problematic. – Craig Estey Sep 20 '16 at 20:14
-
For windows I used `QueryPerformanceCounter`. – Jean-François Fabre Sep 20 '16 at 20:16
-
so I need to multiply by 1000000 right? – Paulo Gasol Sep 20 '16 at 20:17
-
http://stackoverflow.com/questions/26136319/timing-of-multiple-function-calls. – R Sahu Sep 20 '16 at 20:20
-
Possible duplicate of [How do I measure a time interval in C?](http://stackoverflow.com/questions/2150291/how-do-i-measure-a-time-interval-in-c) – Tim Sep 21 '16 at 00:50