This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PING] [PATCH] Preheat CPU in benchtests
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: libc-alpha at sourceware dot org
- Date: Wed, 1 May 2013 21:23:47 +0200
- Subject: [PING] [PATCH] Preheat CPU in benchtests
- References: <20130423061028 dot GA6257 at domone dot kolej dot mff dot cuni dot cz>
Ping,
I need something like this for following patches. This is better than
nothing until environment setting utility is implemented.
OK to commit?
On Tue, Apr 23, 2013 at 08:10:28AM +0200, OndÅej BÃlka wrote:
> Hi,
>
> Benchmarks now are affected by cpu scaling when initialy run at low
> frequency.
>
> Following benchmark runs nonsensial loop first to ensure that benchmark
> are measured at maximal frequency. This greatly cuts time needed to
> get accurate results.
>
---
benchtests/bench-skeleton.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/benchtests/bench-skeleton.c b/benchtests/bench-skeleton.c
index 7359184..2c728bf 100644
--- a/benchtests/bench-skeleton.c
+++ b/benchtests/bench-skeleton.c
@@ -22,6 +22,8 @@
#include <time.h>
#include <inttypes.h>
+volatile double dontoptimize = 0.0;
+
#define TIMESPEC_AFTER(a, b) \
(((a).tv_sec == (b).tv_sec) ? \
((a).tv_nsec > (b).tv_nsec) : \
@@ -32,6 +34,13 @@ main (int argc, char **argv)
unsigned long i, k;
struct timespec start, end, runtime;
+ /* This loop should cause CPU switch to maximal freqency. This makes
+ subsequent measurement more accurate. We need side effect to avoid loop
+ being deleted by compiler. */
+ for(k = 0; k < 1000000; k++)
+ dontoptimize += 23.0 * dontoptimize + 2.1;
+
+
memset (&runtime, 0, sizeof (runtime));
memset (&start, 0, sizeof (start));
memset (&end, 0, sizeof (end));
--
1.7.4.4