[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/6] bitset: tests: exercise the stats too
From: |
Akim Demaille |
Subject: |
[PATCH 6/6] bitset: tests: exercise the stats too |
Date: |
Thu, 19 Nov 2020 07:01:56 +0100 |
* 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 <akim@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 <akim@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
- [PATCH 0/6] bitset: more conversions to ffs, Akim Demaille, 2020/11/19
- [PATCH 1/6] bitset: be sure to always return a value, Akim Demaille, 2020/11/19
- [PATCH 2/6] bitset: check empty and full bitsets, Akim Demaille, 2020/11/19
- [PATCH 3/6] bitset: use ffs where possible in the table implementation, Akim Demaille, 2020/11/19
- [PATCH 4/6] bitset: use ffs where possible in the vector implementation, Akim Demaille, 2020/11/19
- [PATCH 5/6] bitset: tests: try harder to break it, Akim Demaille, 2020/11/19
- [PATCH 6/6] bitset: exercise the stats too, Akim Demaille, 2020/11/19
- [PATCH 6/6] bitset: tests: exercise the stats too,
Akim Demaille <=
- Re: [PATCH 0/6] bitset: more conversions to ffs, Bruno Haible, 2020/11/19