From e6eed717dcecf6f3d964e0ece5294afe9e51ad86 Mon Sep 17 00:00:00 2001 From: Pierre-Marc Fournier Date: Thu, 25 Mar 2010 11:31:00 -0400 Subject: [PATCH] benchmark: fix various problems --- tests/benchmark/bench.c | 9 +++------ tests/benchmark/run | 7 ++++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/benchmark/bench.c b/tests/benchmark/bench.c index ec08130..bc6a389 100644 --- a/tests/benchmark/bench.c +++ b/tests/benchmark/bench.c @@ -11,24 +11,22 @@ #include #include #include +#include static int nr_cpus; static unsigned long nr_events; -pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; void do_stuff(void) { int v; FILE *file; - int lock; v = 1; - lock = pthread_mutex_lock(&mutex); - file = fopen("/tmp/bench.txt", "a"); + file = fopen("/dev/null", "a"); fprintf(file, "%d", v); fclose(file); - lock = pthread_mutex_unlock(&mutex); + time(NULL); #ifdef MARKER trace_mark(ust, event, "event %d", v); @@ -47,7 +45,6 @@ void *function(void *arg) return NULL; } - void usage(char **argv) { printf("Usage: %s nr_cpus nr_events\n", argv[0]); } diff --git a/tests/benchmark/run b/tests/benchmark/run index dfc1125..1e84dc2 100755 --- a/tests/benchmark/run +++ b/tests/benchmark/run @@ -5,7 +5,7 @@ echo "ust benchmark" -NR_EVENTS=2000000 +NR_EVENTS=4000000 NR_CPUS=2 echo "using $NR_CPUS processor(s)" echo "using $NR_EVENTS events per cpu" @@ -14,7 +14,8 @@ echo "using $NR_EVENTS events per cpu" rm -f /tmp/bench.txt # without markers echo ">running without markers" -t1=$(/usr/bin/time -f%e usttrace ./bench1 $NR_CPUS $NR_EVENTS 2>&1 1> /dev/null) +#t1=$(/usr/bin/time -f%e usttrace ./bench1 $NR_CPUS $NR_EVENTS 2>&1 1> /dev/null) +t1=$(/usr/bin/time -f%e ./bench1 $NR_CPUS $NR_EVENTS 2>&1 1> /dev/null) echo " time=$t1 sec" @@ -31,7 +32,7 @@ penalty=$(echo "$t2 - $t1;" | bc) echo "time penalty=$penalty sec" #event = penalty / (nr_events * nr_cpus) -event=$(echo "scale=8; ($penalty / ($NR_EVENTS * $NR_CPUS));" | bc) +event=$(echo "scale=10; ($penalty / ($NR_EVENTS * $NR_CPUS));" | bc) echo "time penalty per event=$event sec" rm -f /tmp/bench.txt -- 2.34.1