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