Skip to content

Instantly share code, notes, and snippets.

@methane
Last active August 29, 2015 14:07
Show Gist options
  • Save methane/5cd42a6da6e144520fdf to your computer and use it in GitHub Desktop.
Save methane/5cd42a6da6e144520fdf to your computer and use it in GitHub Desktop.
[isucon@ip-10-126-163-214 ~]$ uname -a
Linux ip-10-126-163-214 3.14.19-17.43.amzn1.x86_64 #1 SMP Wed Sep 17 22:14:52 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
[isucon@ip-10-126-163-214 ~]$ gcc -O2 -o gt gt.c
[isucon@ip-10-126-163-214 ~]$ time ./gt
called 1000000 times, last value is 1412062819.655371
real 0m0.146s
user 0m0.012s
sys 0m0.132s
#include <stddef.h>
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
int main(int argc, char **argv)
{
struct timeval tv;
int i;
for (i = 0; i < 1000000; ++i)
gettimeofday(&tv, NULL);
printf("called %d times, last value is %d.%d\n", i, (int)tv.tv_sec, (int)tv.tv_usec);
return 0;
}
methane@raring:~$ uname -a
Linux raring 3.13.0-36-generic #63-Ubuntu SMP Wed Sep 3 21:30:07 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
methane@raring:~$ gcc -O2 -o gt gt.c
methane@raring:~$ time ./gt
called 1000000 times, last value is 1412062858.602343
real 0m2.219s
user 0m2.215s
sys 0m0.005s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment