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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ON Pentium(R) Dual-Core CPU E5800 @ 3.20GHz ====> Sum: 4006721