From ef10b624276f126a42fd6a44ecb1d889753121b9 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 20 Oct 2015 17:32:02 +0100 Subject: [PATCH] Allow writing latencies to a separate file --- utils/rspamd_http_bench.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/utils/rspamd_http_bench.c b/utils/rspamd_http_bench.c index 2c7474573..12cbc6f25 100644 --- a/utils/rspamd_http_bench.c +++ b/utils/rspamd_http_bench.c @@ -48,6 +48,7 @@ static guint file_size = 500; static guint pconns = 100; static guint ntests = 3000; static rspamd_inet_addr_t *addr; +static gchar *latencies_file = NULL; static guint32 workers_left = 0; static GOptionEntry entries[] = { @@ -69,6 +70,8 @@ static GOptionEntry entries[] = { "Connect to the specified host (default: localhost)", NULL}, {"key", 'k', 0, G_OPTION_ARG_STRING, &server_key, "Use the specified key (base32 encoded)", NULL}, + {"latency", 'l', 0, G_OPTION_ARG_FILENAME, &latencies_file, + "Write latencies to the specified file", NULL}, {NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL} }; @@ -281,6 +284,7 @@ main (int argc, char **argv) rspamd_mempool_t *pool = rspamd_mempool_new (8192, "http-bench"); struct event term_ev, int_ev, cld_ev; gdouble total_diff; + FILE *lat_file; rspamd_init_libs (); @@ -342,6 +346,20 @@ main (int argc, char **argv) rspamd_printf ("Latency: %.6f ms mean, %.6f dev\n", mean * 1000.0, std * 1000.0); + if (latencies_file) { + lat_file = fopen (latencies_file, "w"); + + if (lat_file) { + guint i; + + for (i = 0; i < nworkers * pconns * ntests; i ++) { + rspamd_fprintf (lat_file, "%.6f\n", latency[i]); + } + + fclose (lat_file); + } + } + rspamd_mempool_delete (pool); return 0; -- 2.39.5