Created
March 21, 2013 17:53
-
-
Save samueljackson92/5215116 to your computer and use it in GitHub Desktop.
C/C++ code for calculating delta time. Output in seconds.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
timeval t1, t2; | |
double elapsedTime; | |
//start timer | |
gettimeofday(&t1, NULL); | |
//do stuff... | |
//stop timer | |
gettimeofday(&t2, NULL); | |
//compute | |
elapsedTime = (t2.tv_sec - t1.tv_sec) * 1000.0; | |
elapsedTime += (t2.tv_usec - t1.tv_usec) / 1000.0; | |
//convert to seconds | |
delta = elapsedTime /1000; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment