Skip to content

Instantly share code, notes, and snippets.

@ex
Created October 30, 2012 03:23
Show Gist options
  • Save ex/3978133 to your computer and use it in GitHub Desktop.
Save ex/3978133 to your computer and use it in GitHub Desktop.
looping from 1 to 1000000000
#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