Timing in C++

1. #include <ctime>

2. clock_t clock(void) returns ticks elapsed since the program started. By dividing a macro CLOCK_PER_SEC(usually 1000), you can easily get an approximate time some process has taken.

3. time_t time(time_t* timer) returns time as seconds elapsed since midnight, January 1, 1970, or -1 in case of error.

4. For time approximate to about 100 milliseconds, it is recomended to use a loop for timing.

actual-time(ms)  = observed-time - baseline-time = 1000/iteration-number-a - 1000/iteration-number-b

 

你可能感兴趣的:(Timing in C++)