Skip to content

Instantly share code, notes, and snippets.

@yohm
Created July 28, 2011 04:44
Show Gist options
  • Save yohm/1110980 to your computer and use it in GitHub Desktop.
Save yohm/1110980 to your computer and use it in GitHub Desktop.
measurement of CPU time using clock()
#include <iostream>
#include <time.h>
int main() {
clock_t start, end;
start = clock();
long sum = 0;
for( long i=0; i < 1<<30; i++) {
sum += i;
}
std::cout << sum << std::endl;
end = clock();
std::cerr << "Elapased time : " << (double)(end-start)/(CLOCKS_PER_SEC) << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment