extern unsigned int irc_dictionary_size(struct Dictionary *dtree);
void irc_dictionary_stats(struct Dictionary *dict, void (*cb)(const char *line, void *privdata), void *privdata);
+void irc_dictionary_stats_walk(void (*cb)(const char *line, void *privdata), void *privdata);
#endif
unsigned int count;
char *id;
unsigned int dirty:1;
+
+ rb_dlink_node node;
};
+static rb_dlink_list dictionary_list = {NULL, NULL, 0};
+
/*
* irc_dictionary_create(const char *name, DCF compare_cb)
*
dtree->compare_cb = compare_cb;
dtree->id = rb_strdup(name);
+ rb_dlinkAdd(dtree, &dtree->node, &dictionary_list);
+
return dtree;
}
rb_free(n);
}
+ rb_dlinkDelete(&dtree->node, &dictionary_list);
+
rb_free(dtree);
}
s_assert(dict != NULL);
- if (dict->id != NULL)
- rb_snprintf(str, sizeof str, "Dictionary stats for %s (%d)",
- dict->id, dict->count);
- else
- rb_snprintf(str, sizeof str, "Dictionary stats for <%p> (%d)",
- (void *)dict, dict->count);
cb(str, privdata);
maxdepth = 0;
sum = stats_recurse(dict->root, 0, &maxdepth);
- rb_snprintf(str, sizeof str, "Depth sum %d Avg depth %d Max depth %d", sum, sum / dict->count, maxdepth);
+ rb_snprintf(str, sizeof str, "%s: Objects: %d, Depth sum: %d, Avg depth: %d, Max depth: %d.", dict->id, dict->count, sum, sum / dict->count, maxdepth);
cb(str, privdata);
- return;
+}
+
+void irc_dictionary_stats_walk(void (*cb)(const char *line, void *privdata), void *privdata)
+{
+ rb_dlink_node *ptr;
+
+ RB_DLINK_FOREACH(ptr, dictionary_list.head)
+ {
+ irc_dictionary_stats(ptr->data, cb, privdata);
+ }
}
}
}
+static void
+stats_hash_cb(const char *buf, void *client_p)
+{
+ sendto_one_numeric(client_p, RPL_STATSDEBUG, "B :%s", buf);
+}
+
static void
stats_hash(struct Client *source_p)
{
hash_stats(source_p);
+
+ sendto_one_numeric(source_p, RPL_STATSDEBUG, "B :Dictionary stats:");
+ irc_dictionary_stats_walk(stats_hash_cb, source_p);
+
+ sendto_one_numeric(source_p, RPL_STATSDEBUG, "B :Radix tree stats:");
+ irc_radixtree_stats_walk(stats_hash_cb, source_p);
}
static void