Staging
v0.8.1
https://github.com/torvalds/linux
Raw File
Tip revision: 6eaae198076080886b9e7d57f4ae06fa782f90ef authored by Linus Torvalds on 23 July 2023, 22:24:10 UTC
Linux 6.5-rc3
Tip revision: 6eaae19
gettimeofday.c
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright 2015, Anton Blanchard, IBM Corp.
 */

#include <sys/time.h>
#include <stdio.h>

#include "utils.h"

static int test_gettimeofday(void)
{
	int i;

	struct timeval tv_start, tv_end, tv_diff;

	gettimeofday(&tv_start, NULL);

	for(i = 0; i < 100000000; i++) {
		gettimeofday(&tv_end, NULL);
	}

	timersub(&tv_start, &tv_end, &tv_diff);

	printf("time = %.6f\n", tv_diff.tv_sec + (tv_diff.tv_usec) * 1e-6);

	return 0;
}

int main(void)
{
	return test_harness(test_gettimeofday, "gettimeofday");
}
back to top