Skip to content

Instantly share code, notes, and snippets.

@zhpengg
Created July 14, 2012 06:52
Show Gist options
  • Save zhpengg/3109763 to your computer and use it in GitHub Desktop.
Save zhpengg/3109763 to your computer and use it in GitHub Desktop.
gettimeofday test
#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;
}
@zhpengg
Copy link
Author

zhpengg commented Jul 14, 2012

On 2.4 GHz Intel Core 2 Duo ===> Sum: 17685931

@zhpengg
Copy link
Author

zhpengg commented Jul 18, 2012

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