* tests/test-bitset.c: Display the stats at the end of the test. * lib/bitset/stats.c (bitset_log_histogram_print): When diplaying the last bin, display "256-..." rather that "256-511", since the last bin does count item greater than or equal to 256. --- ChangeLog | 9 +++++++++ lib/bitset/stats.c | 8 +++++++- tests/test-bitset.c | 4 ++++ 3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog index cd595f41d..55c4e08e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2020-11-19 Akim Demaille <a...@lrde.epita.fr> + + bitset: tests: exercise the stats too + + * tests/test-bitset.c: Display the stats at the end of the test. + * lib/bitset/stats.c (bitset_log_histogram_print): When diplaying the + last bin, display "256-..." rather that "256-511", since the last bin + does count item greater than or equal to 256. + 2020-11-19 Akim Demaille <a...@lrde.epita.fr> bitset: tests: try harder to break it diff --git a/lib/bitset/stats.c b/lib/bitset/stats.c index 5bd44c06a..df9264285 100644 --- a/lib/bitset/stats.c +++ b/lib/bitset/stats.c @@ -154,13 +154,19 @@ bitset_log_histogram_print (FILE *file, const char *name, const char *msg, fprintf (file, "%*d\t%8u (%5.1f%%)\n", max_width, i, bins[i], 100.0 * bins[i] / total); - for (; i < n_bins; i++) + for (; i < n_bins - 1; i++) fprintf (file, "%*lu-%lu\t%8u (%5.1f%%)\n", max_width - ((unsigned) (0.30103 * (i) + 0.9999) + 1), 1UL << (i - 1), (1UL << i) - 1, bins[i], (100.0 * bins[i]) / total); + + fprintf (file, "%*lu-...\t%8u (%5.1f%%)\n", + max_width - ((unsigned) (0.30103 * (i) + 0.9999) + 1), + 1UL << (i - 1), + bins[i], + (100.0 * bins[i]) / total); } } diff --git a/tests/test-bitset.c b/tests/test-bitset.c index 9a2d7c521..6fa656a22 100644 --- a/tests/test-bitset.c +++ b/tests/test-bitset.c @@ -358,6 +358,8 @@ check_attributes (enum bitset_attr attr, int nbits) int main (void) { + bitset_stats_enable (); + for (int i = 0; i < 4; ++i) { /* table bitsets have elements that store 256 bits. bitset_list @@ -382,5 +384,7 @@ int main (void) compare (BITSET_VARIABLE, BITSET_SPARSE); compare (BITSET_VARIABLE, BITSET_FRUGAL); compare (BITSET_VARIABLE, BITSET_GREEDY); + + bitset_stats_dump (stderr); return 0; } -- 2.29.2