diff options
author | mmason <mmason> | 2007-10-25 23:25:45 +0000 |
---|---|---|
committer | mmason <mmason> | 2007-10-25 23:25:45 +0000 |
commit | 70c949c98a4ec9eff552ad1602c7753d46729ec6 (patch) | |
tree | 5fb64b5b168354edc3a8b314cfc6a6723370f7ac /runtime/stat-common.c | |
parent | 0379c17346059afa8dffb07eef82eaea726be6d2 (diff) | |
download | systemtap-steved-70c949c98a4ec9eff552ad1602c7753d46729ec6.tar.gz systemtap-steved-70c949c98a4ec9eff552ad1602c7753d46729ec6.tar.xz systemtap-steved-70c949c98a4ec9eff552ad1602c7753d46729ec6.zip |
stat-common.c: Allow histogram bucket elision to be turned off
with -DHIST_ELISION=<negative #>. Also cleaned up looping code to
prevent unnecessary interation over non-existent buckets.
Diffstat (limited to 'runtime/stat-common.c')
-rw-r--r-- | runtime/stat-common.c | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/runtime/stat-common.c b/runtime/stat-common.c index 8b2f3cf3..a62297bf 100644 --- a/runtime/stat-common.c +++ b/runtime/stat-common.c @@ -222,36 +222,43 @@ static void _stp_stat_print_histogram (Hist st, stat *sd) reprint (HIST_WIDTH, "-"); _stp_print(" count\n"); - eliding=0; + 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; - } - + /* Elide consecutive zero buckets. Specifically, skip + this row if it is zero and some of its nearest + neighbours are also zero. Don't elide zero buckets + if HIST_ELISION is negative */ + if ((long)HIST_ELISION >= 0) { + int k, elide=1; + /* Can't elide more than the total # of buckets */ + int max_elide = min_t(long, HIST_ELISION, st->buckets); + int min_bucket = low_bucket; + int max_bucket = high_bucket; + + if (i - max_elide > min_bucket) + min_bucket = i - max_elide; + if (i + max_elide < max_bucket) + max_bucket = i + max_elide; + for (k = min_bucket; k <= max_bucket; k++) { + if (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) { @@ -266,8 +273,7 @@ static void _stp_stat_print_histogram (Hist st, stat *sd) val = st->start + (i - 1) * st->interval; } else val = _stp_bucket_to_val(i); - - + reprint (val_space - needed_space(val) - over_under, " "); if (over_under) { |