From b5e16fb14006c3813bd785c4c289dcc0f7e37b59 Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Wed, 3 Sep 2008 15:14:33 -0400 Subject: add tool for measuring cycles/sec --- bin/cycles.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 bin/cycles.c (limited to 'bin') diff --git a/bin/cycles.c b/bin/cycles.c new file mode 100644 index 0000000..4e5a078 --- /dev/null +++ b/bin/cycles.c @@ -0,0 +1,25 @@ +#include +#include +#include + +#include "cycles.h" + +int main(int argc, char** argv) +{ + cycles_t t1, t2; + int secs = 1; + + if (argc > 1) { + secs = atoi(argv[1]); + if (secs <= 0) + secs = 1; + } + while (1) { + t1 = get_cycles(); + sleep(secs); + t2 = get_cycles(); + t2 -= t1; + printf("%.2f/sec\n", t2 / (double) secs); + } + return 0; +} -- cgit v1.2.2 From d8130c61443893e490d19da25ea5f32814c5367b Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Sun, 5 Oct 2008 14:45:37 -0400 Subject: nicer output for cycle calibration --- bin/cycles.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/cycles.c b/bin/cycles.c index 4e5a078..a6b9308 100644 --- a/bin/cycles.c +++ b/bin/cycles.c @@ -8,7 +8,7 @@ int main(int argc, char** argv) { cycles_t t1, t2; int secs = 1; - + if (argc > 1) { secs = atoi(argv[1]); if (secs <= 0) @@ -19,7 +19,10 @@ int main(int argc, char** argv) sleep(secs); t2 = get_cycles(); t2 -= t1; - printf("%.2f/sec\n", t2 / (double) secs); + printf("%.2f/sec %.2f/msec %.2f/usec\n", + t2 / (double) secs, + t2 / (secs * 1000.0), + t2 / (secs * 1000000.0)); } return 0; } -- cgit v1.2.2