Commit af1c0a55 authored by Geoff Simmons's avatar Geoff Simmons

Add more stats.

parent 89595fc0
...@@ -445,10 +445,11 @@ PH_Stats(const struct ph * const restrict ph, ...@@ -445,10 +445,11 @@ PH_Stats(const struct ph * const restrict ph,
stats->maxlen = ph->maxlen; stats->maxlen = ph->maxlen;
stats->h2buckets_min = UINT64_MAX; stats->h2buckets_min = UINT64_MAX;
stats->h2strings_min = UINT64_MAX;
for (unsigned i = 0; i <= ph->h1->mask; i++) for (unsigned i = 0; i <= ph->h1->mask; i++)
if (vbit_test(ph->collision, i)) { if (vbit_test(ph->collision, i)) {
struct hash *h2; struct hash *h2;
uint64_t sz; uint64_t sz, nstrings = 0;
h2 = ph->tbl[i].h2; h2 = ph->tbl[i].h2;
CHECK_OBJ_NOTNULL(h2, HASH_MAGIC); CHECK_OBJ_NOTNULL(h2, HASH_MAGIC);
...@@ -460,8 +461,22 @@ PH_Stats(const struct ph * const restrict ph, ...@@ -460,8 +461,22 @@ PH_Stats(const struct ph * const restrict ph,
if (sz > stats->h2buckets_max) if (sz > stats->h2buckets_max)
stats->h2buckets_max = sz; stats->h2buckets_max = sz;
stats->h2buckets_avg += stats->h2buckets_avg +=
(sz - stats->h2buckets_avg) ((double)sz - stats->h2buckets_avg)
/ stats->collisions; / (double)stats->collisions;
for (unsigned j = 0; j < sz; j++) {
if (h2->tbl[j] == UINT_MAX)
continue;
nstrings++;
}
AN(nstrings);
if (nstrings < stats->h2strings_min)
stats->h2strings_min = nstrings;
if (nstrings > stats->h2strings_max)
stats->h2strings_max = nstrings;
stats->h2strings_avg +=
((double)nstrings - stats->h2strings_avg)
/ (double)stats->collisions;
} }
} }
......
...@@ -53,6 +53,9 @@ struct ph_stats { ...@@ -53,6 +53,9 @@ struct ph_stats {
uint64_t h2buckets_min; uint64_t h2buckets_min;
uint64_t h2buckets_max; uint64_t h2buckets_max;
double h2buckets_avg; double h2buckets_avg;
uint64_t h2strings_min;
uint64_t h2strings_max;
double h2strings_avg;
}; };
/* /*
......
...@@ -332,6 +332,9 @@ main(int argc, char *argv[]) ...@@ -332,6 +332,9 @@ main(int argc, char *argv[])
printf("%lu h2 min buckets\n", stats.h2buckets_min); printf("%lu h2 min buckets\n", stats.h2buckets_min);
printf("%lu h2 max buckets\n", stats.h2buckets_max); printf("%lu h2 max buckets\n", stats.h2buckets_max);
printf("%.1f h2 mean buckets\n", stats.h2buckets_avg); printf("%.1f h2 mean buckets\n", stats.h2buckets_avg);
printf("%lu h2 min strings\n", stats.h2strings_min);
printf("%lu h2 max strings\n", stats.h2strings_max);
printf("%.1f h2 mean strings\n", stats.h2strings_avg);
if (do_iters == 0) if (do_iters == 0)
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment