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