Index: scripts/xeno-test.in =================================================================== --- scripts/xeno-test.in (revision 1487) +++ scripts/xeno-test.in (working copy) @@ -200,7 +200,7 @@ loudly ./run -- -T 120 $XENOT_SWITCHTEST '# switchtest' ) ( cd `dirname $0`/../testsuite/switchbench - loudly ./run -- -p 10 -n -l 1000 $XENOT_SWITCHBENCH '# switchbench' + loudly ./run -- -h $XENOT_SWITCHBENCH '# switchbench' ) ( cd `dirname $0`/../testsuite/cyclic loudly ./run -- -p 10 -n -l 1000 $XENOT_CYCLIC '# cyclictest' Index: src/testsuite/switchbench/switchbench.c =================================================================== --- src/testsuite/switchbench/switchbench.c (revision 1487) +++ src/testsuite/switchbench/switchbench.c (working copy) @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -43,17 +44,42 @@ histogram[inabs < HISTOGRAM_CELLS ? inabs : HISTOGRAM_CELLS - 1]++; } -void dump_histogram(void) +void dump_stats(double sum, int total_hits) { - int n; + int n; + double avg, variance = 0; - for (n = 0; n < HISTOGRAM_CELLS; n++) { - long hits = histogram[n]; - if (hits) - fprintf(stderr, "%d - %d us: %ld\n", n, n + 1, hits); - } + avg = sum / total_hits; + for (n = 0; n < HISTOGRAM_CELLS; n++) { + long hits = histogram[n]; + if (hits) + variance += hits * (n-avg) * (n-avg); + } + + /* compute std-deviation (unbiased form) */ + variance /= total_hits - 1; + // variance = sqrt(variance); + + printf("HSS| %9d| %10.3f| %10.3f\n", total_hits, avg, variance); } +void dump_histogram(void) +{ + int n, total_hits = 0; + double sum = 0; + fprintf(stderr, "---|---range-|---samples\n"); + for (n = 0; n < HISTOGRAM_CELLS; n++) { + long hits = histogram[n]; + if (hits) { + total_hits += hits; + sum += n * hits; + fprintf(stderr, "HSD| %d - %d | %10ld\n", + n, n + 1, hits); + } + } + dump_stats(sum, total_hits); +} + void event(void *cookie) { int err; @@ -180,8 +206,14 @@ } if (sampling_period == 0) - sampling_period = 100000; /* ns */ + sampling_period = 100000; /* ns */ + if (nsamples <= 0) { + fprintf(stderr, "disregarding -n <%lld>, using -n <100> us\n", + nsamples); + nsamples = 100000; /* ns */ + } + signal(SIGINT, SIG_IGN); signal(SIGTERM, SIG_IGN);