Created
April 12, 2012 04:13
-
-
Save uhziel/2364556 to your computer and use it in GitHub Desktop.
test clock() in c. from http://www.acm.uiuc.edu/webmonkeys/book/c_guide/2.15.html#clock.
This file contains 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
#include<time.h> | |
#include<stdio.h> | |
int main(void) | |
{ | |
clock_t ticks1, ticks2; | |
ticks1=clock(); | |
ticks2=ticks1; | |
while((ticks2-ticks1)/CLOCKS_PER_SEC<1) { | |
ticks2=clock(); | |
} | |
printf("Took %ld ticks to wait one second.\n",ticks2-ticks1); | |
printf("This value should be the same as CLOCKS_PER_SEC which is %ld.\n",CLOCKS_PER_SEC); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment