summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavej <davej>2003-03-14 18:21:12 +0000
committerdavej <davej>2003-03-14 18:21:12 +0000
commit7135e500e289dc526434bc0eae6e5ec0a960a702 (patch)
tree9045250e18f4f6afe118e63e9c4e2d910962c0ca
parent8324a62a9d22cd46cc620fa1944fb70b50b08662 (diff)
* bench/bench.h: improve timing routine a little. still needs work.
* bench/benchmarks.c: remove lea (eax), 1(eax) test for now.
-rw-r--r--ChangeLog2
-rw-r--r--bench/bench.h16
-rw-r--r--bench/benchmarks.c4
3 files changed, 14 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 78f1771..d37df7b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,8 @@
2003-3-14 Dave Jones <davej@codemonkey.org.uk>
* identify.c: decode 0xc0000000 range cpuids if available.
+ * bench/bench.h: improve timing routine a little. still needs work.
+ * bench/benchmarks.c: remove lea (eax), 1(eax) test for now.
2003-3-13 Dave Jones <davej@codemonkey.org.uk>
diff --git a/bench/bench.h b/bench/bench.h
index 0d5dd09..0eb578f 100644
--- a/bench/bench.h
+++ b/bench/bench.h
@@ -1,15 +1,21 @@
#define rdtsc() ({ unsigned long a,d; asm volatile("rdtsc":"=a" (a), "=d" (d)); a; })
+#define NREPS 1000
+
#define TIME(x,y) \
- bmin = 100000; \
- for (i = 0; i < 1000; i++) { \
- unsigned long bstart,bend; \
+{ \
+ int i,j; \
+ unsigned long bmin,bstart,bend; \
+ for (j=0; j<100; j++) { \
+ bmin = 100000; \
bstart = rdtsc(); \
- x; \
+ for (i=0; i<NREPS; i++) \
+ x; \
bend = rdtsc(); \
bend -= bstart; \
if (bend < bmin) \
bmin = bend; \
} \
- printf(y ": %ld cycles\n", bmin);
+ printf(y ": %ld cycles\n", bmin/NREPS); \
+}
diff --git a/bench/benchmarks.c b/bench/benchmarks.c
index 6c5d0ab..12b49a7 100644
--- a/bench/benchmarks.c
+++ b/bench/benchmarks.c
@@ -8,8 +8,7 @@
void show_benchmarks()
{
- int i, ret, tmp=0;
- unsigned long bmin;
+ int ret, tmp=0;
if (show_bench != 1)
return;
@@ -19,7 +18,6 @@ void show_benchmarks()
TIME(asm volatile("addl $1,0(%esp)"), "addl");
TIME(asm volatile("lock ; addl $1,0(%esp)"), "locked add");
- TIME(asm volatile("lea 1(%eax),%eax"), "lea 1(%%eax),%%eax");
TIME(asm volatile("bswap %0" : "=r" (tmp) : "0" (tmp)), "bswap");
}