From dab2e6f4be3f05374c9672026031c6534838beb1 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 15 Dec 2016 15:14:33 +0000 Subject: [Minor] Add some timing for mime parsing tool --- utils/mime_tool.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'utils') diff --git a/utils/mime_tool.c b/utils/mime_tool.c index c2dde4fdd..fb4b7ee5e 100644 --- a/utils/mime_tool.c +++ b/utils/mime_tool.c @@ -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); -- cgit v1.2.3