xref: /kernel/linux/linux-5.10/tools/testing/selftests/powerpc/benchmarks/gettimeofday.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /kernel/linux/linux-5.10/tools/testing/selftests/powerpc/benchmarks/
18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright 2015, Anton Blanchard, IBM Corp.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <sys/time.h>
78c2ecf20Sopenharmony_ci#include <stdio.h>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include "utils.h"
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_cistatic int test_gettimeofday(void)
128c2ecf20Sopenharmony_ci{
138c2ecf20Sopenharmony_ci	int i;
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci	struct timeval tv_start, tv_end;
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci	gettimeofday(&tv_start, NULL);
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci	for(i = 0; i < 100000000; i++) {
208c2ecf20Sopenharmony_ci		gettimeofday(&tv_end, NULL);
218c2ecf20Sopenharmony_ci	}
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci	printf("time = %.6f\n", tv_end.tv_sec - tv_start.tv_sec + (tv_end.tv_usec - tv_start.tv_usec) * 1e-6);
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci	return 0;
268c2ecf20Sopenharmony_ci}
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ciint main(void)
298c2ecf20Sopenharmony_ci{
308c2ecf20Sopenharmony_ci	return test_harness(test_gettimeofday, "gettimeofday");
318c2ecf20Sopenharmony_ci}
32

Indexes created Thu Nov 07 10:32:03 CST 2024