-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Michael Neuling
authored and
Michael Ellerman
committed
Oct 1, 2015
1 parent
26cd835
commit d17475d
Showing
4 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
gettimeofday |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
} |