Created
November 29, 2012 08:48
-
-
Save zhouji/4167658 to your computer and use it in GitHub Desktop.
calculate time spending in C++
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
int test1(){ | |
cout<< " OK " << endl; | |
KestrelServer ks("localhost",22133); | |
int max = 1000000; | |
struct timeval start, end; | |
long mtime, seconds, useconds; | |
gettimeofday(&start, NULL); | |
int count = 0; | |
char data[1024]; | |
data[1023]='\0'; | |
const char * msg = data; | |
while(count < max){ | |
ks.Send("scoring",msg,5); | |
count++; | |
} | |
gettimeofday(&end, NULL); | |
seconds = end.tv_sec - start.tv_sec; | |
useconds = end.tv_usec - start.tv_usec; | |
mtime = ((seconds) * 1000 + useconds/1000.0) + 0.5; | |
cout << mtime << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment