Skip to content

Instantly share code, notes, and snippets.

@REPOmAN2v2
Created September 4, 2014 12:42
Show Gist options
  • Save REPOmAN2v2/ac02bafaa571624b841a to your computer and use it in GitHub Desktop.
Save REPOmAN2v2/ac02bafaa571624b841a to your computer and use it in GitHub Desktop.
getTime()
float getTime()
{
static uint_least64_t start = 0;
struct timeval tv;
if (start == 0) {
gettimeofday(&tv,NULL);
start = 1000000 * tv.tv_sec + tv.tv_usec;
return 0.0f;
}
uint_least64_t counter = 0;
gettimeofday(&tv,NULL);
counter = 1000000 * tv.tv_sec + tv.tv_usec;
return (counter - start) / 1000000.0f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment