Created
July 28, 2011 04:44
-
-
Save yohm/1110980 to your computer and use it in GitHub Desktop.
measurement of CPU time using clock()
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 <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