Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Michael Neuling and committed by
Michael Ellerman
d17475d9 26cd835e

+45 -1
+1 -1
tools/testing/selftests/powerpc/Makefile
··· 12 12 13 13 export CFLAGS 14 14 15 - SUB_DIRS = pmu copyloops mm tm primitives stringloops vphn switch_endian dscr 15 + SUB_DIRS = pmu copyloops mm tm primitives stringloops vphn switch_endian dscr benchmarks 16 16 17 17 endif 18 18
+1
tools/testing/selftests/powerpc/benchmarks/.gitignore
··· 1 + gettimeofday
+12
tools/testing/selftests/powerpc/benchmarks/Makefile
··· 1 + TEST_PROGS := gettimeofday 2 + 3 + CFLAGS += -O2 4 + 5 + all: $(TEST_PROGS) 6 + 7 + $(TEST_PROGS): ../harness.c 8 + 9 + include ../../lib.mk 10 + 11 + clean: 12 + rm -f $(TEST_PROGS) *.o
+31
tools/testing/selftests/powerpc/benchmarks/gettimeofday.c
··· 1 + /* 2 + * Copyright 2015, Anton Blanchard, IBM Corp. 3 + * Licensed under GPLv2. 4 + */ 5 + 6 + #include <sys/time.h> 7 + #include <stdio.h> 8 + 9 + #include "utils.h" 10 + 11 + static int test_gettimeofday(void) 12 + { 13 + int i; 14 + 15 + struct timeval tv_start, tv_end; 16 + 17 + gettimeofday(&tv_start, NULL); 18 + 19 + for(i = 0; i < 100000000; i++) { 20 + gettimeofday(&tv_end, NULL); 21 + } 22 + 23 + printf("time = %.6f\n", tv_end.tv_sec - tv_start.tv_sec + (tv_end.tv_usec - tv_start.tv_usec) * 1e-6); 24 + 25 + return 0; 26 + } 27 + 28 + int main(void) 29 + { 30 + return test_harness(test_gettimeofday, "gettimeofday"); 31 + }