diff options
author | fche <fche> | 2007-09-22 16:45:13 +0000 |
---|---|---|
committer | fche <fche> | 2007-09-22 16:45:13 +0000 |
commit | 2fa08ae4a89a80af291bca046626b035be0ea569 (patch) | |
tree | 5b8f826879b91c28dfc5db474ecd8920613ad291 | |
parent | 051286ecc4321199897351004dca9a84760c2cec (diff) | |
download | systemtap-steved-2fa08ae4a89a80af291bca046626b035be0ea569.tar.gz systemtap-steved-2fa08ae4a89a80af291bca046626b035be0ea569.tar.xz systemtap-steved-2fa08ae4a89a80af291bca046626b035be0ea569.zip |
PR 5057: histogram zero elision
2007-09-22 Frank Ch. Eigler <fche@elastic.org>
PR 5057.
* stat-common.c (_stp_stat_print_histogram): Elide consecutive
zero rows beyond 2*STAT_ELISION+1.
(STAT_ELISION): New parameter, default 2.
2007-09-22 Frank Ch. Eigler <fche@elastic.org>
PR 5057.
* systemtap.maps/linear_nearlyempty.*: New test for
histogram printing elision.
-rw-r--r-- | runtime/ChangeLog | 7 | ||||
-rw-r--r-- | runtime/stat-common.c | 36 | ||||
-rw-r--r-- | testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | testsuite/systemtap.maps/linear_nearlyempty.exp | 25 | ||||
-rw-r--r-- | testsuite/systemtap.maps/linear_nearlyempty.stp | 18 |
5 files changed, 92 insertions, 0 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog index 48787132..54a3554e 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,3 +1,10 @@ +2007-09-22 Frank Ch. Eigler <fche@elastic.org> + + PR 5057. + * stat-common.c (_stp_stat_print_histogram): Elide consecutive + zero rows beyond 2*STAT_ELISION+1. + (STAT_ELISION): New parameter, default 2. + 2007-09-21 Martin Hunt <hunt@redhat.com> PR 5024 * stat-common.c (_stp_stat_print_histogram): Change diff --git a/runtime/stat-common.c b/runtime/stat-common.c index 7a6f439b..8b2f3cf3 100644 --- a/runtime/stat-common.c +++ b/runtime/stat-common.c @@ -133,11 +133,17 @@ static int _stp_val_to_bucket(int64_t val) #define HIST_WIDTH 50 #endif +#ifndef HIST_ELISION +#define HIST_ELISION 2 /* zeroes before and after */ +#endif + + static void _stp_stat_print_histogram (Hist st, stat *sd) { int scale, i, j, val_space, cnt_space; int low_bucket = -1, high_bucket = 0, over = 0, under = 0; int64_t val, v, max = 0; + int eliding = 0; if (st->type != HIST_LOG && st->type != HIST_LINEAR) return; @@ -215,8 +221,38 @@ static void _stp_stat_print_histogram (Hist st, stat *sd) _stp_print("value |"); reprint (HIST_WIDTH, "-"); _stp_print(" count\n"); + + eliding=0; for (i = low_bucket; i <= high_bucket; i++) { int over_under = 0; + + /* Elide consecutive zero buckets. Specifically, skip + this row if it is zero and some of its nearest + neighbours are also zero. */ + int k; + int elide=1; + for (k=i-HIST_ELISION; k<=i+HIST_ELISION; k++) + { + if (k >= 0 && k < st->buckets && sd->histogram[k] != 0) + elide = 0; + } + if (elide) + { + eliding = 1; + continue; + } + + /* State change: we have elided some rows, but now are about + to print a new one. So let's print a mark on the vertical + axis to represent the missing rows. */ + if (eliding) + { + reprint (val_space, " "); + _stp_print(" ~\n"); + eliding = 0; + } + + if (st->type == HIST_LINEAR) { if (i == 0) { /* underflow */ diff --git a/testsuite/ChangeLog b/testsuite/ChangeLog index 4c5d811b..a2317b5f 100644 --- a/testsuite/ChangeLog +++ b/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2007-09-22 Frank Ch. Eigler <fche@elastic.org> + + PR 5057. + * systemtap.maps/linear_nearlyempty.*: New test for + histogram printing elision. + 2007-09-21 Martin Hunt <hunt@redhat.com> * systemtap.maps/linear*: Updated linear histogram tests. diff --git a/testsuite/systemtap.maps/linear_nearlyempty.exp b/testsuite/systemtap.maps/linear_nearlyempty.exp new file mode 100644 index 00000000..dfb5e9ef --- /dev/null +++ b/testsuite/systemtap.maps/linear_nearlyempty.exp @@ -0,0 +1,25 @@ +# Test nearly empty linear histogram + +set test "linear_nearlyempty" +set ::result_string {count=2 +sum=1443 +min=444 +max=999 +avg=721 +value |-------------------------------------------------- count + 300 | 0 + 350 | 0 + 400 |@ 1 + 450 | 0 + 500 | 0 + ~ + 850 | 0 + 900 | 0 + 950 |@ 1 + 1000 | 0 + 1050 | 0 +} + +stap_run2 $srcdir/$subdir/$test.stp + + diff --git a/testsuite/systemtap.maps/linear_nearlyempty.stp b/testsuite/systemtap.maps/linear_nearlyempty.stp new file mode 100644 index 00000000..f0b70607 --- /dev/null +++ b/testsuite/systemtap.maps/linear_nearlyempty.stp @@ -0,0 +1,18 @@ +# test that we can check the count of an empty array + +global agg + +probe begin +{ + agg <<< 444 + agg <<< 999 + printf("count=%d\n", @count(agg)) + if (@count(agg) > 0) { + printf("sum=%d\n", @sum(agg)) + printf("min=%d\n", @min(agg)) + printf("max=%d\n", @max(agg)) + printf("avg=%d\n", @avg(agg)) + print(@hist_linear(agg, 0, 1500, 50)) + } + exit() +} |