Created
May 29, 2011 15:14
-
-
Save ironsmile/997849 to your computer and use it in GitHub Desktop.
ctimer for blago
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 <iostream> | |
#include <sys/time.h> | |
int main (int argc, char * const argv[]) { | |
timeval start, end; | |
long mtime, seconds, useconds; | |
gettimeofday(&start, NULL); | |
int * arr = new int[100000000]; | |
for (int i = 0; i < 100000000; ++i) { | |
*(arr+i) = i; | |
} | |
for (int i = 0; i < 100000000; ++i){ | |
; | |
} | |
gettimeofday(&end, NULL); | |
seconds = end.tv_sec - start.tv_sec; | |
useconds = end.tv_usec - start.tv_usec; | |
mtime = ((seconds) * 1000 + useconds/1000.0); | |
std::cout<<mtime; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment