[Minor] Add some timing for mime parsing tool

This commit is contained in:
Vsevolod Stakhov 2016-12-15 15:14:33 +00:00
parent 14deba94c8
commit dab2e6f4be

Vedi File

@ -23,6 +23,7 @@
#include "mime_parser.h"
#include "unix-std.h"
static gdouble total_time = 0.0;
static void
rspamd_show_normal (struct rspamd_mime_part *part)
@ -81,6 +82,7 @@ rspamd_process_file (struct rspamd_config *cfg, const gchar *fname, gint mode)
GError *err = NULL;
struct rspamd_mime_part *part;
guint i;
gdouble ts1, ts2;
fd = open (fname, O_RDONLY);
@ -106,11 +108,16 @@ rspamd_process_file (struct rspamd_config *cfg, const gchar *fname, gint mode)
task->msg.begin = map;
task->msg.len = st.st_size;
ts1 = rspamd_get_ticks ();
if (!rspamd_mime_parse_task (task, &err)) {
rspamd_fprintf (stderr, "cannot parse %s: %e\n", fname, err);
g_error_free (err);
}
ts2 = rspamd_get_ticks ();
total_time += ts2 - ts1;
for (i = 0; i < task->parts->len; i ++) {
part = g_ptr_array_index (task->parts, i);
@ -152,6 +159,8 @@ main (int argc, char **argv)
}
}
rspamd_printf ("Total time parsing: %.4f seconds\n", total_time);
rspamd_log_close (logger);
REF_RELEASE (cfg);