Created
July 14, 2012 06:52
-
-
Save zhpengg/3109763 to your computer and use it in GitHub Desktop.
gettimeofday test
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 <stdio.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#include <sys/time.h> | |
#include <signal.h> | |
static long couter = 0; | |
void sigalarm(int sig) | |
{ | |
printf("Sum: %ld\n", couter); | |
exit(1); | |
} | |
int main() | |
{ | |
struct timeval now; | |
signal(SIGALRM, sigalarm); | |
alarm(1); | |
while (1) { | |
gettimeofday(&now, NULL); | |
couter++; | |
} | |
return 0; | |
} |
On Intel(R) Xeon(R) CPU E5620 @ 2.40GHz ===> Sum: 23774087
On 2.4 GHz Intel Core 2 Duo ===> Sum: 17685931
ON Pentium(R) Dual-Core CPU E5800 @ 3.20GHz ====> Sum: 4006721
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On Intel(R) Xeon(R) CPU 5150 @ 2.66GHz ===> Sum: 14975283