diff options
author | Michael Neuling <mikey@neuling.org> | 2015-09-25 06:01:39 +0200 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2015-10-01 08:52:02 +0200 |
commit | d17475d906fde8e9fe39fff3873b07380ed6da76 (patch) | |
tree | b9e554db6653fd121bb325297618a8591e09cbff /tools/testing/selftests/powerpc/benchmarks/gettimeofday.c | |
parent | powerpc/slb: Use a local to avoid multiple calls to get_slb_shadow() (diff) | |
download | linux-d17475d906fde8e9fe39fff3873b07380ed6da76.tar.xz linux-d17475d906fde8e9fe39fff3873b07380ed6da76.zip |
powerpc/selftest: Add gettimeofday() benchmark
This adds a benchmark directory to the powerpc selftests and adds a
gettimeofday() benchmark to it.
Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'tools/testing/selftests/powerpc/benchmarks/gettimeofday.c')
-rw-r--r-- | tools/testing/selftests/powerpc/benchmarks/gettimeofday.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/testing/selftests/powerpc/benchmarks/gettimeofday.c b/tools/testing/selftests/powerpc/benchmarks/gettimeofday.c new file mode 100644 index 000000000000..3af3c21e8036 --- /dev/null +++ b/tools/testing/selftests/powerpc/benchmarks/gettimeofday.c @@ -0,0 +1,31 @@ +/* + * Copyright 2015, Anton Blanchard, IBM Corp. + * Licensed under GPLv2. + */ + +#include <sys/time.h> +#include <stdio.h> + +#include "utils.h" + +static int test_gettimeofday(void) +{ + int i; + + struct timeval tv_start, tv_end; + + gettimeofday(&tv_start, NULL); + + for(i = 0; i < 100000000; i++) { + gettimeofday(&tv_end, NULL); + } + + printf("time = %.6f\n", tv_end.tv_sec - tv_start.tv_sec + (tv_end.tv_usec - tv_start.tv_usec) * 1e-6); + + return 0; +} + +int main(void) +{ + return test_harness(test_gettimeofday, "gettimeofday"); +} |