From fa60355b7aacd1f4b10f1497792787288c0632ff Mon Sep 17 00:00:00 2001 From: hunt Date: Wed, 13 Jul 2005 06:34:00 +0000 Subject: 2005-07-12 Martin Hunt * bench/run_bench (do_time): Use ttest instead of "time". Fix processor computation. * bench/ttest.c: Like "time.c" except takes an argument to adjust loop size. Also computes system time + user time instead of real time. Added a warmup loop to get consistent results from cpus which adjust speed based on load. * bench/time.c: Replaced by ttest.c --- runtime/probes/bench/time.c | 68 --------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 runtime/probes/bench/time.c (limited to 'runtime/probes/bench/time.c') diff --git a/runtime/probes/bench/time.c b/runtime/probes/bench/time.c deleted file mode 100644 index fb423276..00000000 --- a/runtime/probes/bench/time.c +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -typedef unsigned long long uint64; - -struct timeval t1; - -void start(struct timeval *tv) -{ - gettimeofday (tv, NULL); -} - -uint64 time_delta(struct timeval *start, struct timeval *stop) -{ - uint64 secs, usecs; - - secs = stop->tv_sec - start->tv_sec; - usecs = stop->tv_usec - start->tv_usec; - if (usecs < 0) { - secs--; - usecs += 1000000; - } - return secs * 1000000 + usecs; -} - -uint64 stop(struct timeval *begin) -{ - struct timeval end; - gettimeofday (&end, NULL); - return time_delta (begin, &end); -} - - -int main() -{ - int fd, i; - char buf[1024]; - uint64 nsecs; - - system ("touch foo"); - fd = open ("foo", O_RDWR); - - start(&t1); - for (i = 0; i < 1000000; i++) { - if (read (fd, buf, 0) < 0) - perror("read"); - } - nsecs = stop(&t1) / 1000; - - printf("%lld ", nsecs); - - start(&t1); - for (i = 0; i < 1000000; i++) { - if (write (fd, buf, 0) < 0) - perror("write"); - } - nsecs = stop(&t1) / 1000; - close (fd); - - printf("%lld\n", nsecs); - - return 0; -} -- cgit