mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-08-24 11:58:18 +00:00

Commitc814bf9589
("powerpc/selftests: Use timersub() for gettimeofday()"), got the order of arguments to timersub() wrong, leading to a negative time delta being reported, eg: test: gettimeofday tags: git_version:v6.12-rc5-409-gdddf291c3030 time = -3.297781 success: gettimeofday The correct order is minuend, subtrahend, which in this case is end, start. Which gives: test: gettimeofday tags: git_version:v6.12-rc5-409-gdddf291c3030-dirty time = 3.300650 success: gettimeofday Fixes:c814bf9589
("powerpc/selftests: Use timersub() for gettimeofday()") Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/20241218114347.428108-1-mpe@ellerman.id.au
34 lines
551 B
C
34 lines
551 B
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_end, &tv_start, &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");
|
|
}
|