Skip to content

Instantly share code, notes, and snippets.

@toxicFork
Created November 5, 2013 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toxicFork/7315788 to your computer and use it in GitHub Desktop.
Save toxicFork/7315788 to your computer and use it in GitHub Desktop.
Time elapsed
#define CLOCK_PRECISION (1E9)
struct timespec requestStart, requestEnd;
clock_gettime(CLOCK_REALTIME, &requestStart);
func(grid);
clock_gettime(CLOCK_REALTIME, &requestEnd);
// Calculate the time it took
double accum = ( requestEnd.tv_sec - requestStart.tv_sec )
+ ( requestEnd.tv_nsec - requestStart.tv_nsec )
/ CLOCK_PRECISION;
printf("Time elapsed: %fs\n",accum);
return accum;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment