elt2 = ucl_object_lookup (*o2, "frequency");
if (elt1 && elt2) {
- order1 = ucl_object_toint (elt1);
- order2 = ucl_object_toint (elt2);
+ order1 = ucl_object_todouble (elt1) * 100000;
+ order2 = ucl_object_todouble (elt2) * 100000;
}
}
else if (g_ascii_strcasecmp (args[0], "time") == 0) {
static void
rspamc_counters_output (FILE *out, ucl_object_t *obj)
{
- const ucl_object_t *cur, *sym, *weight, *freq, *tim;
+ const ucl_object_t *cur, *sym, *weight, *freq, *freq_dev, *tim;
ucl_object_iter_t iter = NULL;
gchar fmt_buf[64], dash_buf[82];
gint l, max_len = INT_MIN, i;
+ static const gint dashes = 44;
if (obj->type != UCL_ARRAY) {
rspamd_printf ("Bad output\n");
if (sym != NULL) {
l = sym->len;
if (l > max_len) {
- max_len = MIN (40, l);
+ max_len = MIN (sizeof (dash_buf) - dashes - 1, l);
}
}
}
rspamd_snprintf (fmt_buf, sizeof (fmt_buf),
- "| %%3s | %%%ds | %%6s | %%9s | %%9s |\n", max_len);
- memset (dash_buf, '-', 40 + max_len);
- dash_buf[40 + max_len] = '\0';
+ "| %%3s | %%%ds | %%7s | %%13s | %%7s |\n", max_len);
+ memset (dash_buf, '-', dashes + max_len);
+ dash_buf[dashes + max_len] = '\0';
printf ("Symbols cache\n");
printf (" %s \n", dash_buf);
if (tty) {
printf ("\033[1m");
}
- printf (fmt_buf, "Pri", "Symbol", "Weight", "Frequency", "Avg. time");
+ printf (fmt_buf, "Pri", "Symbol", "Weight", "Frequency", "Time");
+ printf (" %s \n", dash_buf);
+ printf (fmt_buf, "", "", "", "hits/sec", "usec");
if (tty) {
printf ("\033[0m");
}
rspamd_snprintf (fmt_buf, sizeof (fmt_buf),
- "| %%3d | %%%ds | %%6.1f | %%9.3f | %%9.3f |\n", max_len);
+ "| %%3d | %%%ds | %%7.1f | %%6.3f(%%5.3f) | %%7.4f |\n", max_len);
iter = NULL;
i = 0;
sym = ucl_object_lookup (cur, "symbol");
weight = ucl_object_lookup (cur, "weight");
freq = ucl_object_lookup (cur, "frequency");
+ freq_dev = ucl_object_lookup (cur, "frequency_stddev");
tim = ucl_object_lookup (cur, "time");
+
if (sym && weight && freq && tim) {
printf (fmt_buf, i,
ucl_object_tostring (sym),
ucl_object_todouble (weight),
ucl_object_todouble (freq),
+ ucl_object_todouble (freq_dev),
ucl_object_todouble (tim));
}
i++;
group_symbols = ucl_object_typed_new (UCL_ARRAY);
while (g_hash_table_iter_next (&sit, &k, &v)) {
- gdouble tm = 0.0, freq = 0;
+ gdouble tm = 0.0, freq = 0, freq_dev = 0;
sym = v;
sym_obj = ucl_object_typed_new (UCL_OBJECT);
}
if (rspamd_symbols_cache_stat_symbol (session->ctx->cfg->cache,
- sym->name, &freq, &tm)) {
+ sym->name, &freq, &freq_dev, &tm)) {
ucl_object_insert_key (sym_obj,
ucl_object_fromdouble (freq),
"frequency", 0, false);
+ ucl_object_insert_key (sym_obj,
+ ucl_object_fromdouble (freq_dev),
+ "frequency_stddev", 0, false);
ucl_object_insert_key (sym_obj,
ucl_object_fromdouble (tm),
"time", 0, false);