From 18cbed4750d64451e5210454ee7dbb3a288f0bc3 Mon Sep 17 00:00:00 2001 From: kojima Date: Fri, 14 Jan 2000 23:37:20 +0000 Subject: [PATCH] benchmark on pentium stuff --- wrlib/bench.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 wrlib/bench.h diff --git a/wrlib/bench.h b/wrlib/bench.h new file mode 100644 index 00000000..4c6861c7 --- /dev/null +++ b/wrlib/bench.h @@ -0,0 +1,68 @@ + + + +inline static void +cycle_bench(int start) +{ + static volatile unsigned int start_cycle; + + if (start) { + asm volatile + ("pushl %%edx \n\t" + "rdtsc \n\t" + "movl %%eax,%0 \n\t" + "cld \n\t" + "popl %%edx \n\t" + "nop \n\t" + "nop \n\t" + "nop \n\t" + "nop \n\t" + "nop \n\t" + "nop \n\t" + "nop \n\t" + "nop \n\t" + : "=m" (start_cycle) : : "eax", "edx"); + } else { + volatile int end; + + asm volatile + ("pushl %%edx \n\t" + "clc \n\t" + "rdtsc \n\t" + "movl %%eax, %0 \n\t" + "popl %%edx \n\t" + : "=m" (end) : : "eax", "edx"); + + printf("Cycle count = %u\n", end - start_cycle - 68); + } +} + + + +#if 0 +// seems linux doesnt allow user progs to exec rdpcm.. +inline static void +cache_bench(int start) +{ + static int start_cycle; + + if (start) { + asm volatile( + "movl $1,%%ecx \n\t" + "rdpmc \n\t" + "movl %%eax,%0 \n\t" + : "=m" (start_cycle)); + } else { + int end; + + asm volatile( + "movl $1,%%ecx \n\t" + "rdpmc \n\t" + "movl %%eax,%0" + : "=m" (end)); + + printf("Cache reloads counted = %i\n", end - start_cycle); + } +} + +#endif -- 2.11.4.GIT