Created
October 30, 2012 03:23
-
-
Save ex/3978133 to your computer and use it in GitHub Desktop.
looping from 1 to 1000000000
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
#include <stdio.h> | |
#include <time.h> | |
int main() { | |
int i; | |
unsigned int q = 0xbabecafe; | |
// Get start time | |
clock_t tm = clock(); | |
// Loop 10 ^ 9 times | |
for (i = 1; i <= 1000000000; ++i) { | |
// Do something... | |
q ^= (unsigned int)i; | |
} | |
// Get elapsed time: ~ 0.8 seconds (Intel Core 2 Duo 2.4 GHz) | |
printf("Elapsed seconds: %.2f\n", (float)(clock() - tm)/CLOCKS_PER_SEC); | |
printf("%x\n", q); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment