From a53a992f1fe0c26ce089c66d7310d1a2a5566d49 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20W=C3=BCrdig?= Date: Tue, 11 Apr 2006 09:03:04 +0000 Subject: [PATCH] added get_count function for distribution tables [r7616] --- ir/stat/distrib.c | 19 +++++++++++++++++-- ir/stat/firmstat_t.h | 5 +++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ir/stat/distrib.c b/ir/stat/distrib.c index 0f78b4aeb..452ae1052 100644 --- a/ir/stat/distrib.c +++ b/ir/stat/distrib.c @@ -173,6 +173,21 @@ void stat_insert_int_distrib_tbl(distrib_tbl_t *tbl, int key) stat_insert_distrib_tbl(tbl, (const void *)key); } +/* + * returns the sum over all counters in a distribution table + */ +int stat_get_count_distrib_tbl(distrib_tbl_t *tbl) +{ + distrib_entry_t *entry; + int sum = 0; + + for (entry = pset_first(tbl->hash_map); entry; entry = pset_next(tbl->hash_map)) { + sum += cnt_to_int(&entry->cnt); + } + + return sum; +} + /* * calculates the mean value of a distribution */ @@ -236,11 +251,11 @@ double stat_calc_avg_distrib_tbl(distrib_tbl_t *tbl) return 0.0; sum = cnt_to_dbl(&entry->cnt); - count = entry->cnt.cnt[0]; + count = cnt_to_int(&entry->cnt); for (entry = pset_next(tbl->hash_map); entry; entry = pset_next(tbl->hash_map)) { sum += cnt_to_dbl(&entry->cnt) * (int)entry->object; - count += entry->cnt.cnt[0]; + count += cnt_to_int(&entry->cnt); } } else { diff --git a/ir/stat/firmstat_t.h b/ir/stat/firmstat_t.h index fc571d554..7c6f4e987 100644 --- a/ir/stat/firmstat_t.h +++ b/ir/stat/firmstat_t.h @@ -348,6 +348,11 @@ void stat_insert_distrib_tbl(distrib_tbl_t *tbl, const void *object); */ void stat_insert_int_distrib_tbl(distrib_tbl_t *tbl, int key); +/** + * returns the sum over all counters in a distribution table + */ +int stat_get_count_distrib_tbl(distrib_tbl_t *tbl); + /** * calculates the mean value of a distribution. */ -- 2.20.1