powerpc/selftest: Add gettimeofday() benchmark
authorMichael Neuling <mikey@neuling.org>
Fri, 25 Sep 2015 04:01:39 +0000 (14:01 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 1 Oct 2015 06:52:02 +0000 (16:52 +1000)
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>
tools/testing/selftests/powerpc/Makefile
tools/testing/selftests/powerpc/benchmarks/.gitignore [new file with mode: 0644]
tools/testing/selftests/powerpc/benchmarks/Makefile [new file with mode: 0644]
tools/testing/selftests/powerpc/benchmarks/gettimeofday.c [new file with mode: 0644]

index 03ca2e64b3fcd291c58311848c18794b5514d1d9..847adf6e8d16b9481b8c483c57fa77cfb378c51a 100644 (file)
@@ -12,7 +12,7 @@ CFLAGS := -Wall -O2 -flto -Wall -Werror -DGIT_VERSION='"$(GIT_VERSION)"' -I$(CUR
 
 export CFLAGS
 
-SUB_DIRS = pmu copyloops mm tm primitives stringloops vphn switch_endian dscr
+SUB_DIRS = pmu copyloops mm tm primitives stringloops vphn switch_endian dscr benchmarks
 
 endif
 
diff --git a/tools/testing/selftests/powerpc/benchmarks/.gitignore b/tools/testing/selftests/powerpc/benchmarks/.gitignore
new file mode 100644 (file)
index 0000000..b4709ea
--- /dev/null
@@ -0,0 +1 @@
+gettimeofday
diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
new file mode 100644 (file)
index 0000000..5fa4870
--- /dev/null
@@ -0,0 +1,12 @@
+TEST_PROGS := gettimeofday
+
+CFLAGS += -O2
+
+all: $(TEST_PROGS)
+
+$(TEST_PROGS): ../harness.c
+
+include ../../lib.mk
+
+clean:
+       rm -f $(TEST_PROGS) *.o
diff --git a/tools/testing/selftests/powerpc/benchmarks/gettimeofday.c b/tools/testing/selftests/powerpc/benchmarks/gettimeofday.c
new file mode 100644 (file)
index 0000000..3af3c21
--- /dev/null
@@ -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");
+}
This page took 0.026042 seconds and 5 git commands to generate.