From 3a18979dd18ba8cdd96367d2ad18c456f26c6f20 Mon Sep 17 00:00:00 2001 From: hunt Date: Wed, 12 Sep 2007 18:37:47 +0000 Subject: 2007-09-12 Martin Hunt * map-stat.c (_stp_map_new_hstat_log): Set buckets to HIST_LOG_BUCKETS. (_stp_pmap_new_hstat_log): Ditto. (_stp_map_new_hstat_linear): Call _stp_stat_calc_buckets(). (_stp_pmap_new_hstat_linear): Ditto. * stat.h (STP_MAX_BUCKETS): Define.. (HIST_LOG_BUCKETS): Define. * stat.c (_stp_stat_init): Call _stp_stat_calc_buckets(). * stat-common.c (_stp_stat_calc_buckets): New function. Common bucket calculation and error reporting code. (_stp_bucket_to_val): New function. (_stp_val_to_bucket): Renamed and now handles negative numbers. (_stp_stat_print_histogram): Handle negative values in log histograms. (__stp_stat_add): Cleanup.. * map-gen.c (_stp_map_new): Remove buckets param for HIST_LOG. * pmap-gen.c (_stp_pmap_new): Ditto. --- runtime/stat.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'runtime/stat.c') diff --git a/runtime/stat.c b/runtime/stat.c index f4e205aa..3df1d063 100644 --- a/runtime/stat.c +++ b/runtime/stat.c @@ -85,21 +85,15 @@ Stat _stp_stat_init (int type, ...) va_start (ap, type); if (type == HIST_LOG) { - buckets = va_arg(ap, int); + buckets = HIST_LOG_BUCKETS; } else { start = va_arg(ap, int); stop = va_arg(ap, int); interval = va_arg(ap, int); - if (interval == 0) { - _stp_warn("histogram: interval cannot be zero.\n"); - return NULL; - } - buckets = (stop - start) / interval; - if ((stop - start) % interval) buckets++; - if (buckets > 128) { - _stp_warn("histogram: Interval is too small. Maximum buckets is 128.\n"); + + buckets = _stp_stat_calc_buckets(stop, start, interval); + if (!buckets) return NULL; - } } va_end (ap); } -- cgit