1*d17475d9SMichael Neuling /* 2*d17475d9SMichael Neuling * Copyright 2015, Anton Blanchard, IBM Corp. 3*d17475d9SMichael Neuling * Licensed under GPLv2. 4*d17475d9SMichael Neuling */ 5*d17475d9SMichael Neuling 6*d17475d9SMichael Neuling #include <sys/time.h> 7*d17475d9SMichael Neuling #include <stdio.h> 8*d17475d9SMichael Neuling 9*d17475d9SMichael Neuling #include "utils.h" 10*d17475d9SMichael Neuling 11*d17475d9SMichael Neuling static int test_gettimeofday(void) 12*d17475d9SMichael Neuling { 13*d17475d9SMichael Neuling int i; 14*d17475d9SMichael Neuling 15*d17475d9SMichael Neuling struct timeval tv_start, tv_end; 16*d17475d9SMichael Neuling 17*d17475d9SMichael Neuling gettimeofday(&tv_start, NULL); 18*d17475d9SMichael Neuling 19*d17475d9SMichael Neuling for(i = 0; i < 100000000; i++) { 20*d17475d9SMichael Neuling gettimeofday(&tv_end, NULL); 21*d17475d9SMichael Neuling } 22*d17475d9SMichael Neuling 23*d17475d9SMichael Neuling printf("time = %.6f\n", tv_end.tv_sec - tv_start.tv_sec + (tv_end.tv_usec - tv_start.tv_usec) * 1e-6); 24*d17475d9SMichael Neuling 25*d17475d9SMichael Neuling return 0; 26*d17475d9SMichael Neuling } 27*d17475d9SMichael Neuling 28*d17475d9SMichael Neuling int main(void) 29*d17475d9SMichael Neuling { 30*d17475d9SMichael Neuling return test_harness(test_gettimeofday, "gettimeofday"); 31*d17475d9SMichael Neuling } 32