Commit e4fe5963 authored by Geoff Simmons's avatar Geoff Simmons

Add PH stats for secondary hash key vector lengths.

parent 38879fa6
......@@ -458,6 +458,7 @@ PH_Stats(const struct ph * const restrict ph,
stats->h2buckets_min = UINT64_MAX;
stats->h2strings_min = UINT64_MAX;
stats->h2klen_min = SIZE_MAX;
for (unsigned i = 0; i <= ph->h1->mask; i++)
if (vbit_test(ph->collision, i)) {
struct hash *h2;
......@@ -476,6 +477,14 @@ PH_Stats(const struct ph * const restrict ph,
((double)sz - stats->h2buckets_avg)
/ (double)stats->collisions;
if (h2->l < stats->h2klen_min)
stats->h2klen_min = h2->l;
if (h2->l > stats->h2klen_max)
stats->h2klen_max = h2->l;
stats->h2klen_avg +=
((double)h2->l - stats->h2klen_avg)
/ (double)stats->collisions;
for (unsigned j = 0; j < sz; j++) {
if (h2->tbl[j] == UINT_MAX)
continue;
......@@ -493,6 +502,8 @@ PH_Stats(const struct ph * const restrict ph,
stats->h2buckets_min = 0;
if (stats->h2strings_min == UINT64_MAX)
stats->h2strings_min = 0;
if (stats->h2klen_min == SIZE_MAX)
stats->h2klen_min = 0;
}
void
......
......@@ -56,6 +56,9 @@ struct ph_stats {
uint64_t h2strings_min;
uint64_t h2strings_max;
double h2strings_avg;
size_t h2klen_min;
size_t h2klen_max;
double h2klen_avg;
};
/*
......
......@@ -335,6 +335,9 @@ main(int argc, char *argv[])
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);
printf("%lu h2 min key vector length\n", stats.h2klen_min);
printf("%lu h2 max key vector length\n", stats.h2klen_max);
printf("%.1f h2 mean key vector length\n", stats.h2klen_avg);
if (do_iters == 0)
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