0001
0002
0003
0004
0005
0006 #include <sys/time.h>
0007 #include <stdio.h>
0008
0009 #include "utils.h"
0010
0011 static int test_gettimeofday(void)
0012 {
0013 int i;
0014
0015 struct timeval tv_start, tv_end;
0016
0017 gettimeofday(&tv_start, NULL);
0018
0019 for(i = 0; i < 100000000; i++) {
0020 gettimeofday(&tv_end, NULL);
0021 }
0022
0023 printf("time = %.6f\n", tv_end.tv_sec - tv_start.tv_sec + (tv_end.tv_usec - tv_start.tv_usec) * 1e-6);
0024
0025 return 0;
0026 }
0027
0028 int main(void)
0029 {
0030 return test_harness(test_gettimeofday, "gettimeofday");
0031 }