Return to Snippet

Revision: 43952
at April 4, 2011 06:32 by killerovsky


Initial Code
struct timeval start, end, delta;
assert(gettimeofday(&start, NULL) != -1);

// LAPS should be huge (about a million, probably)
for (int i = 0; i < LAPS; i++)
	test_function();
	
assert(gettimeofday(&end, NULL) != -1);
timersub(&end, &start, &delta);
uint64_t delta_ns = (delta.tv_sec * NSEC_PER_SEC + delta.tv_usec * NSEC_PER_USEC) / LAPS;

Initial URL

                                

Initial Description

                                

Initial Title
How to measure time of execution

Initial Tags
Development

Initial Language
C