-
-static void
-output_hash(struct Client *source_p, const char *name, int length, int *counts, unsigned long deepest)
-{
- unsigned long total = 0;
- int i;
- char buf[128];
-
- sendto_one_numeric(source_p, RPL_STATSDEBUG,
- "B :%s Hash Statistics", name);
-
- snprintf(buf, sizeof buf, "%.3f%%",
- (float) ((counts[0]*100) / (float) length));
- sendto_one_numeric(source_p, RPL_STATSDEBUG,
- "B :Size: %d Empty: %d (%s)",
- length, counts[0], buf);
-
- for(i = 1; i < 11; i++)
- {
- total += (counts[i] * i);
- }
-
- /* dont want to divide by 0! --fl */
- if(counts[0] != length)
- {
- snprintf(buf, sizeof buf, "%.3f/%.3f",
- (float) (total / (length - counts[0])),
- (float) (total / length));
- sendto_one_numeric(source_p, RPL_STATSDEBUG,
- "B :Average depth: %s Highest depth: %lu",
- buf, deepest);
- }
-
- for(i = 0; i < 11; i++)
- {
- sendto_one_numeric(source_p, RPL_STATSDEBUG,
- "B :Nodes with %d entries: %d",
- i, counts[i]);
- }
-}
-
-
-static void
-count_hash(struct Client *source_p, rb_dlink_list *table, int length, const char *name)
-{
- int counts[11];
- unsigned long deepest = 0;
- int i;
-
- memset(counts, 0, sizeof(counts));
-
- for(i = 0; i < length; i++)
- {
- if(rb_dlink_list_length(&table[i]) >= 10)
- counts[10]++;
- else
- counts[rb_dlink_list_length(&table[i])]++;
-
- if(rb_dlink_list_length(&table[i]) > deepest)
- deepest = rb_dlink_list_length(&table[i]);
- }
-
- output_hash(source_p, name, length, counts, deepest);
-}
-
-void
-hash_stats(struct Client *source_p)
-{
- count_hash(source_p, channelTable, CH_MAX, "Channel");
- sendto_one_numeric(source_p, RPL_STATSDEBUG, "B :--");
- count_hash(source_p, hostTable, HOST_MAX, "Hostname");
-}