summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt17
-rw-r--r--config.h.in1
-rw-r--r--src/client/rspamc.c2
-rw-r--r--src/client/rspamdclient.c4
-rw-r--r--src/libserver/protocol.c2
-rw-r--r--src/libserver/re_cache.c4
-rw-r--r--src/libserver/symbols_cache.c16
-rw-r--r--src/libserver/task.c2
-rw-r--r--src/libutil/expression.c4
-rw-r--r--src/libutil/util.c27
-rw-r--r--src/libutil/util.h2
-rw-r--r--src/lua/lua_util.c7
-rw-r--r--test/rspamd_cryptobox_test.c78
-rw-r--r--test/rspamd_http_test.c24
-rw-r--r--test/rspamd_radix_test.c24
15 files changed, 126 insertions, 88 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2deefa15f..0acfefb75 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1120,6 +1120,23 @@ ELSE()
MESSAGE(STATUS "atomic builtins are supported")
ENDIF()
+CHECK_C_SOURCE_RUNS("
+#include <x86intrin.h>
+int main(int argc, char **argv) {
+ unsigned l;
+ if (__builtin_ia32_rdtscp(&l)) {
+ return 0;
+ }
+ return -1;
+}
+" HAVE_RDTSCP)
+
+IF(NOT HAVE_RDTSCP)
+ MESSAGE(STATUS "rdtscp intrinsic is -NOT- supported")
+ELSE()
+ MESSAGE(STATUS "rdtscp intrinsic is supported")
+ENDIF()
+
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
# In linux, we need to mount /run/shm to test which could be unavailable
# on a build system. On the other hand, we know that linux has stupid
diff --git a/config.h.in b/config.h.in
index ef2bb1097..6f8d3c48c 100644
--- a/config.h.in
+++ b/config.h.in
@@ -71,6 +71,7 @@
#cmakedefine HAVE_POSIX_FALLOCATE 1
#cmakedefine HAVE_PTHREAD_PROCESS_SHARED 1
#cmakedefine HAVE_PWD_H 1
+#cmakedefine HAVE_RDTSCP 1
#cmakedefine HAVE_READPASSPHRASE_H 1
#cmakedefine HAVE_SA_SIGINFO 1
#cmakedefine HAVE_SANE_SHMEM 1
diff --git a/src/client/rspamc.c b/src/client/rspamc.c
index bd199fda3..08c23a1b8 100644
--- a/src/client/rspamc.c
+++ b/src/client/rspamc.c
@@ -1481,7 +1481,7 @@ rspamc_client_cb (struct rspamd_client_connection *conn,
struct rspamc_callback_data *cbdata = (struct rspamc_callback_data *)ud;
struct rspamc_command *cmd;
FILE *out = stdout;
- gdouble finish = rspamd_get_ticks (), diff;
+ gdouble finish = rspamd_get_ticks (FALSE), diff;
const gchar *body;
gsize body_len;
diff --git a/src/client/rspamdclient.c b/src/client/rspamdclient.c
index 7ea096183..4a58b3628 100644
--- a/src/client/rspamdclient.c
+++ b/src/client/rspamdclient.c
@@ -114,7 +114,7 @@ rspamd_client_finish_handler (struct rspamd_http_connection *conn,
if (!c->req_sent) {
c->req_sent = TRUE;
- c->send_time = rspamd_get_ticks ();
+ c->send_time = rspamd_get_ticks (FALSE);
rspamd_http_connection_reset (c->http_conn);
rspamd_http_connection_read_message (c->http_conn,
c->req,
@@ -435,7 +435,7 @@ rspamd_client_command (struct rspamd_client_connection *conn,
req->msg->url = rspamd_fstring_append (req->msg->url, command, strlen (command));
conn->req = req;
- conn->start_time = rspamd_get_ticks ();
+ conn->start_time = rspamd_get_ticks (FALSE);
if (compressed) {
rspamd_http_connection_write_message (conn->http_conn, req->msg, NULL,
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 6180adccb..d8973dea6 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -1126,7 +1126,7 @@ rspamd_protocol_write_ucl (struct rspamd_task *task,
cached, rspamd_protocol_cached_dtor);
/* We also set scan time here */
- task->time_real_finish = rspamd_get_ticks ();
+ task->time_real_finish = rspamd_get_ticks (FALSE);
task->time_virtual_finish = rspamd_get_virtual_ticks ();
}
diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c
index c51caff8f..d34cc6824 100644
--- a/src/libserver/re_cache.c
+++ b/src/libserver/re_cache.c
@@ -508,7 +508,7 @@ rspamd_re_cache_process_pcre (struct rspamd_re_runtime *rt,
pr = rspamd_random_double_fast ();
if (pr > 0.9) {
- t1 = rspamd_get_ticks ();
+ t1 = rspamd_get_ticks (TRUE);
}
while (rspamd_regexp_search (re,
@@ -536,7 +536,7 @@ rspamd_re_cache_process_pcre (struct rspamd_re_runtime *rt,
}
if (pr > 0.9) {
- t2 = rspamd_get_ticks ();
+ t2 = rspamd_get_ticks (TRUE);
if (t2 - t1 > slow_time) {
msg_info_task ("regexp '%16s' took %.2f seconds to execute",
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index de0a806fa..ece7895da 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -1270,7 +1270,7 @@ rspamd_symbols_cache_check_symbol (struct rspamd_task *task,
struct rspamd_task **ptask;
lua_State *L;
gboolean check = TRUE;
- const gdouble slow_diff_limit = 1e5;
+ const gdouble slow_diff_limit = 1e7;
if (item->func) {
@@ -1309,10 +1309,10 @@ rspamd_symbols_cache_check_symbol (struct rspamd_task *task,
rspamd_symbols_cache_watcher_cb,
item);
msg_debug_task ("execute %s, %d", item->symbol, item->id);
- t1 = rspamd_get_ticks ();
+ t1 = rspamd_get_ticks (TRUE);
item->func (task, item->user_data);
- t2 = rspamd_get_ticks ();
- diff = (t2 - t1) * 1e6;
+ t2 = rspamd_get_ticks (TRUE);
+ diff = (t2 - t1);
if (G_UNLIKELY (RSPAMD_TASK_IS_PROFILING (task))) {
rspamd_task_profile_set (task, item->symbol, diff);
@@ -1323,8 +1323,8 @@ rspamd_symbols_cache_check_symbol (struct rspamd_task *task,
}
if (diff > slow_diff_limit) {
- msg_info_task ("slow rule: %s: %d ms", item->symbol,
- (gint)(diff / 1000.));
+ msg_info_task ("slow rule: %s: %.0f ticks", item->symbol,
+ diff);
}
if (rspamd_worker_is_normal (task->worker)) {
@@ -2038,7 +2038,7 @@ rspamd_symbols_cache_resort_cb (gint fd, short what, gpointer ud)
cache = cbdata->cache;
/* Plan new event */
tm = rspamd_time_jitter (cache->reload_time, 0);
- cur_ticks = rspamd_get_ticks ();
+ cur_ticks = rspamd_get_ticks (TRUE);
msg_debug_cache ("resort symbols cache, next reload in %.2f seconds", tm);
g_assert (cache != NULL);
evtimer_set (&cbdata->resort_ev, rspamd_symbols_cache_resort_cb, cbdata);
@@ -2138,7 +2138,7 @@ rspamd_symbols_cache_start_refresh (struct symbols_cache * cache,
struct rspamd_cache_refresh_cbdata *cbdata;
cbdata = rspamd_mempool_alloc0 (cache->static_pool, sizeof (*cbdata));
- cbdata->last_resort = rspamd_get_ticks ();
+ cbdata->last_resort = rspamd_get_ticks (TRUE);
cbdata->ev_base = ev_base;
cbdata->w = w;
cbdata->cache = cache;
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 04ce2b759..8bb8ecaa0 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -80,7 +80,7 @@ rspamd_task_new (struct rspamd_worker *worker, struct rspamd_config *cfg,
}
gettimeofday (&new_task->tv, NULL);
- new_task->time_real = rspamd_get_ticks ();
+ new_task->time_real = rspamd_get_ticks (FALSE);
new_task->time_virtual = rspamd_get_virtual_ticks ();
if (pool == NULL) {
diff --git a/src/libutil/expression.c b/src/libutil/expression.c
index b49935cb4..dae574da5 100644
--- a/src/libutil/expression.c
+++ b/src/libutil/expression.c
@@ -1007,7 +1007,7 @@ rspamd_ast_process_node (struct rspamd_expression *expr, gint flags, GNode *node
*/
if ((expr->evals & 0x1F) == (GPOINTER_TO_UINT (node) >> 4 & 0x1F)) {
calc_ticks = TRUE;
- t1 = rspamd_get_ticks ();
+ t1 = rspamd_get_ticks (TRUE);
}
elt->value = expr->subr->process (data, elt->p.atom);
@@ -1021,7 +1021,7 @@ rspamd_ast_process_node (struct rspamd_expression *expr, gint flags, GNode *node
}
if (calc_ticks) {
- t2 = rspamd_get_ticks ();
+ t2 = rspamd_get_ticks (TRUE);
elt->p.atom->avg_ticks += ((t2 - t1) - elt->p.atom->avg_ticks) /
(expr->evals);
}
diff --git a/src/libutil/util.c b/src/libutil/util.c
index f2d9d41b0..f022b4689 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -70,6 +70,9 @@
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
+#ifdef HAVE_RDTSCP
+#include <x86intrin.h>
+#endif
#include <math.h> /* for pow */
#include "cryptobox.h"
@@ -1761,24 +1764,36 @@ restart:
}
gdouble
-rspamd_get_ticks (void)
+rspamd_get_ticks (gboolean rdtsc_ok)
{
gdouble res;
+#ifdef HAVE_RDTSCP
+ guint tmp;
+ guint64 r64;
+
+ if (rdtsc_ok) {
+ r64 = __builtin_ia32_rdtscp (&tmp);
+ /* Preserve lower 52 bits */
+ res = r64 & ((1ULL << 53) - 1);
+ return res;
+ }
+
+#endif
#ifdef HAVE_CLOCK_GETTIME
struct timespec ts;
gint clk_id = CLOCK_MONOTONIC;
-#ifdef CLOCK_MONOTONIC_FAST
+# ifdef CLOCK_MONOTONIC_FAST
clk_id = CLOCK_MONOTONIC_FAST;
-#endif
-#ifdef CLOCK_MONOTONIC_COARSE
+# endif
+# ifdef CLOCK_MONOTONIC_COARSE
clk_id = CLOCK_MONOTONIC_COARSE;
-#endif
+# endif
clock_gettime (clk_id, &ts);
res = (double)ts.tv_sec + ts.tv_nsec / 1000000000.;
-#elif defined(__APPLE__)
+# elif defined(__APPLE__)
res = mach_absolute_time () / 1000000000.;
#else
struct timeval tv;
diff --git a/src/libutil/util.h b/src/libutil/util.h
index d8a1eae60..ab677210e 100644
--- a/src/libutil/util.h
+++ b/src/libutil/util.h
@@ -295,7 +295,7 @@ gint rspamd_read_passphrase (gchar *buf, gint size, gint rwflag, gpointer key);
* Portably return the current clock ticks as seconds
* @return
*/
-gdouble rspamd_get_ticks (void);
+gdouble rspamd_get_ticks (gboolean rdtsc_ok);
/**
* Portably return the current virtual clock ticks as seconds
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index 538c8d9f7..b2041c704 100644
--- a/src/lua/lua_util.c
+++ b/src/lua/lua_util.c
@@ -1439,8 +1439,13 @@ static gint
lua_util_get_ticks (lua_State *L)
{
gdouble ticks;
+ gboolean rdtsc = FALSE;
- ticks = rspamd_get_ticks ();
+ if (lua_isboolean (L, 1)) {
+ rdtsc = lua_toboolean (L, 1);
+ }
+
+ ticks = rspamd_get_ticks (rdtsc);
lua_pushnumber (L, ticks);
return 1;
diff --git a/test/rspamd_cryptobox_test.c b/test/rspamd_cryptobox_test.c
index b7cbe2a16..b0d02160a 100644
--- a/test/rspamd_cryptobox_test.c
+++ b/test/rspamd_cryptobox_test.c
@@ -174,89 +174,89 @@ rspamd_cryptobox_test_func (void)
seg = g_slice_alloc0 (sizeof (*seg) * max_seg * 10);
/* Test baseline */
- t1 = rspamd_get_ticks ();
+ t1 = rspamd_get_ticks (TRUE);
rspamd_cryptobox_encrypt_nm_inplace (begin, end - begin, nonce, key, mac,
mode);
- t2 = rspamd_get_ticks ();
+ t2 = rspamd_get_ticks (TRUE);
check_result (key, nonce, mac, begin, end);
- msg_info ("baseline encryption: %.6f", t2 - t1);
+ msg_info ("baseline encryption: %.0f", t2 - t1);
mode = RSPAMD_CRYPTOBOX_MODE_NIST;
- t1 = rspamd_get_ticks ();
+ t1 = rspamd_get_ticks (TRUE);
rspamd_cryptobox_encrypt_nm_inplace (begin,
end - begin,
nonce,
key,
mac,
mode);
- t2 = rspamd_get_ticks ();
+ t2 = rspamd_get_ticks (TRUE);
check_result (key, nonce, mac, begin, end);
- msg_info ("openssl baseline encryption: %.6f", t2 - t1);
+ msg_info ("openssl baseline encryption: %.0f", t2 - t1);
mode = RSPAMD_CRYPTOBOX_MODE_25519;
start:
/* A single chunk as vector */
seg[0].data = begin;
seg[0].len = end - begin;
- t1 = rspamd_get_ticks ();
+ t1 = rspamd_get_ticks (TRUE);
rspamd_cryptobox_encryptv_nm_inplace (seg, 1, nonce, key, mac, mode);
- t2 = rspamd_get_ticks ();
+ t2 = rspamd_get_ticks (TRUE);
check_result (key, nonce, mac, begin, end);
- msg_info ("bulk encryption: %.6f", t2 - t1);
+ msg_info ("bulk encryption: %.0f", t2 - t1);
/* Two chunks as vector */
seg[0].data = begin;
seg[0].len = (end - begin) / 2;
seg[1].data = begin + seg[0].len;
seg[1].len = (end - begin) - seg[0].len;
- t1 = rspamd_get_ticks ();
+ t1 = rspamd_get_ticks (TRUE);
rspamd_cryptobox_encryptv_nm_inplace (seg, 2, nonce, key, mac, mode);
- t2 = rspamd_get_ticks ();
+ t2 = rspamd_get_ticks (TRUE);
check_result (key, nonce, mac, begin, end);
- msg_info ("2 equal chunks encryption: %.6f", t2 - t1);
+ msg_info ("2 equal chunks encryption: %.0f", t2 - t1);
seg[0].data = begin;
seg[0].len = 1;
seg[1].data = begin + seg[0].len;
seg[1].len = (end - begin) - seg[0].len;
- t1 = rspamd_get_ticks ();
+ t1 = rspamd_get_ticks (TRUE);
rspamd_cryptobox_encryptv_nm_inplace (seg, 2, nonce, key, mac, mode);
- t2 = rspamd_get_ticks ();
+ t2 = rspamd_get_ticks (TRUE);
check_result (key, nonce, mac, begin, end);
- msg_info ("small and large chunks encryption: %.6f", t2 - t1);
+ msg_info ("small and large chunks encryption: %.0f", t2 - t1);
seg[0].data = begin;
seg[0].len = (end - begin) - 3;
seg[1].data = begin + seg[0].len;
seg[1].len = (end - begin) - seg[0].len;
- t1 = rspamd_get_ticks ();
+ t1 = rspamd_get_ticks (TRUE);
rspamd_cryptobox_encryptv_nm_inplace (seg, 2, nonce, key, mac, mode);
- t2 = rspamd_get_ticks ();
+ t2 = rspamd_get_ticks (TRUE);
check_result (key, nonce, mac, begin, end);
- msg_info ("large and small chunks encryption: %.6f", t2 - t1);
+ msg_info ("large and small chunks encryption: %.0f", t2 - t1);
/* Random two chunks as vector */
seg[0].data = begin;
seg[0].len = ottery_rand_range (end - begin - 1) + 1;
seg[1].data = begin + seg[0].len;
seg[1].len = (end - begin) - seg[0].len;
- t1 = rspamd_get_ticks ();
+ t1 = rspamd_get_ticks (TRUE);
rspamd_cryptobox_encryptv_nm_inplace (seg, 2, nonce, key, mac, mode);
- t2 = rspamd_get_ticks ();
+ t2 = rspamd_get_ticks (TRUE);
check_result (key, nonce, mac, begin, end);
- msg_info ("random 2 chunks encryption: %.6f", t2 - t1);
+ msg_info ("random 2 chunks encryption: %.0f", t2 - t1);
/* 3 specific chunks */
seg[0].data = begin;
@@ -265,47 +265,47 @@ start:
seg[1].len = 2049;
seg[2].data = begin + seg[0].len + seg[1].len;
seg[2].len = (end - begin) - seg[0].len - seg[1].len;
- t1 = rspamd_get_ticks ();
+ t1 = rspamd_get_ticks (TRUE);
rspamd_cryptobox_encryptv_nm_inplace (seg, 3, nonce, key, mac, mode);
- t2 = rspamd_get_ticks ();
+ t2 = rspamd_get_ticks (TRUE);
check_result (key, nonce, mac, begin, end);
- msg_info ("small, medium and large chunks encryption: %.6f", t2 - t1);
+ msg_info ("small, medium and large chunks encryption: %.0f", t2 - t1);
cnt = create_random_split (seg, max_seg, begin, end);
- t1 = rspamd_get_ticks ();
+ t1 = rspamd_get_ticks (TRUE);
rspamd_cryptobox_encryptv_nm_inplace (seg, cnt, nonce, key, mac, mode);
- t2 = rspamd_get_ticks ();
+ t2 = rspamd_get_ticks (TRUE);
check_result (key, nonce, mac, begin, end);
- msg_info ("random split of %d chunks encryption: %.6f", cnt, t2 - t1);
+ msg_info ("random split of %d chunks encryption: %.0f", cnt, t2 - t1);
cnt = create_realistic_split (seg, max_seg, begin, end);
- t1 = rspamd_get_ticks ();
+ t1 = rspamd_get_ticks (TRUE);
rspamd_cryptobox_encryptv_nm_inplace (seg, cnt, nonce, key, mac, mode);
- t2 = rspamd_get_ticks ();
+ t2 = rspamd_get_ticks (TRUE);
check_result (key, nonce, mac, begin, end);
- msg_info ("realistic split of %d chunks encryption: %.6f", cnt, t2 - t1);
+ msg_info ("realistic split of %d chunks encryption: %.0f", cnt, t2 - t1);
cnt = create_constrainted_split (seg, max_seg + 1, 32, begin, end);
- t1 = rspamd_get_ticks ();
+ t1 = rspamd_get_ticks (TRUE);
rspamd_cryptobox_encryptv_nm_inplace (seg, cnt, nonce, key, mac, mode);
- t2 = rspamd_get_ticks ();
+ t2 = rspamd_get_ticks (TRUE);
check_result (key, nonce, mac, begin, end);
- msg_info ("constrainted split of %d chunks encryption: %.6f", cnt, t2 - t1);
+ msg_info ("constrainted split of %d chunks encryption: %.0f", cnt, t2 - t1);
for (i = 0; i < random_fuzz_cnt; i ++) {
ms = ottery_rand_range (i % max_seg * 2) + 1;
cnt = create_random_split (seg, ms, begin, end);
- t1 = rspamd_get_ticks ();
+ t1 = rspamd_get_ticks (TRUE);
rspamd_cryptobox_encryptv_nm_inplace (seg, cnt, nonce, key, mac, mode);
- t2 = rspamd_get_ticks ();
+ t2 = rspamd_get_ticks (TRUE);
check_result (key, nonce, mac, begin, end);
@@ -316,9 +316,9 @@ start:
for (i = 0; i < random_fuzz_cnt; i ++) {
ms = ottery_rand_range (i % max_seg * 2) + 1;
cnt = create_realistic_split (seg, ms, begin, end);
- t1 = rspamd_get_ticks ();
+ t1 = rspamd_get_ticks (TRUE);
rspamd_cryptobox_encryptv_nm_inplace (seg, cnt, nonce, key, mac, mode);
- t2 = rspamd_get_ticks ();
+ t2 = rspamd_get_ticks (TRUE);
check_result (key, nonce, mac, begin, end);
@@ -329,9 +329,9 @@ start:
for (i = 0; i < random_fuzz_cnt; i ++) {
ms = ottery_rand_range (i % max_seg * 10) + 1;
cnt = create_constrainted_split (seg, ms, i, begin, end);
- t1 = rspamd_get_ticks ();
+ t1 = rspamd_get_ticks (TRUE);
rspamd_cryptobox_encryptv_nm_inplace (seg, cnt, nonce, key, mac, mode);
- t2 = rspamd_get_ticks ();
+ t2 = rspamd_get_ticks (TRUE);
check_result (key, nonce, mac, begin, end);
diff --git a/test/rspamd_http_test.c b/test/rspamd_http_test.c
index 19ee50ea1..e70c396aa 100644
--- a/test/rspamd_http_test.c
+++ b/test/rspamd_http_test.c
@@ -134,7 +134,7 @@ rspamd_client_finish (struct rspamd_http_connection *conn,
{
struct client_cbdata *cb = conn->ud;
- *(cb->lat) = rspamd_get_ticks () * 1000. - cb->ts;
+ *(cb->lat) = rspamd_get_ticks (FALSE) * 1000. - cb->ts;
close (conn->fd);
rspamd_http_connection_unref (conn);
g_free (cb);
@@ -175,7 +175,7 @@ rspamd_http_client_func (const gchar *path, rspamd_inet_addr_t *addr,
}
cb = g_malloc (sizeof (*cb));
- cb->ts = rspamd_get_ticks () * 1000.;
+ cb->ts = rspamd_get_ticks (FALSE) * 1000.;
cb->lat = latency;
rspamd_http_connection_write_message (conn, msg, NULL, NULL, cb,
fd, NULL, ev_base);
@@ -319,9 +319,9 @@ rspamd_http_test_func (void)
rspamd_http_client_func (filepath + sizeof ("/tmp") - 1, addr,
NULL, NULL, c, ev_base, &latency[i * pconns + j]);
}
- ts1 = rspamd_get_ticks ();
+ ts1 = rspamd_get_ticks (FALSE);
event_base_loop (ev_base, 0);
- ts2 = rspamd_get_ticks ();
+ ts2 = rspamd_get_ticks (FALSE);
diff = (ts2 - ts1) * 1000.0;
total_diff += diff;
}
@@ -355,9 +355,9 @@ rspamd_http_test_func (void)
rspamd_http_client_func (filepath + sizeof ("/tmp") - 1, addr,
client_key, peer_key, c, ev_base, &latency[i * pconns + j]);
}
- ts1 = rspamd_get_ticks ();
+ ts1 = rspamd_get_ticks (FALSE);
event_base_loop (ev_base, 0);
- ts2 = rspamd_get_ticks ();
+ ts2 = rspamd_get_ticks (FALSE);
diff = (ts2 - ts1) * 1000.0;
total_diff += diff;
}
@@ -385,9 +385,9 @@ rspamd_http_test_func (void)
rspamd_http_client_func (filepath + sizeof ("/tmp") - 1, addr,
client_key, peer_key, c, ev_base, &latency[i * pconns + j]);
}
- ts1 = rspamd_get_ticks ();
+ ts1 = rspamd_get_ticks (FALSE);
event_base_loop (ev_base, 0);
- ts2 = rspamd_get_ticks ();
+ ts2 = rspamd_get_ticks (FALSE);
diff = (ts2 - ts1) * 1000.0;
total_diff += diff;
}
@@ -434,9 +434,9 @@ rspamd_http_test_func (void)
ev_base,
&latency[i * pconns + j]);
}
- ts1 = rspamd_get_ticks ();
+ ts1 = rspamd_get_ticks (FALSE);
event_base_loop (ev_base, 0);
- ts2 = rspamd_get_ticks ();
+ ts2 = rspamd_get_ticks (FALSE);
diff = (ts2 - ts1) * 1000.0;
total_diff += diff;
}
@@ -472,9 +472,9 @@ rspamd_http_test_func (void)
ev_base,
&latency[i * pconns + j]);
}
- ts1 = rspamd_get_ticks ();
+ ts1 = rspamd_get_ticks (FALSE);
event_base_loop (ev_base, 0);
- ts2 = rspamd_get_ticks ();
+ ts2 = rspamd_get_ticks (FALSE);
diff = (ts2 - ts1) * 1000.0;
total_diff += diff;
}
diff --git a/test/rspamd_radix_test.c b/test/rspamd_radix_test.c
index 0f114bf80..b3a185399 100644
--- a/test/rspamd_radix_test.c
+++ b/test/rspamd_radix_test.c
@@ -242,17 +242,17 @@ rspamd_radix_test_func (void)
btrie = btrie_init (pool);
msg_info ("btrie performance (%z elts)", nelts);
- ts1 = rspamd_get_ticks ();
+ ts1 = rspamd_get_ticks (TRUE);
for (i = 0; i < nelts; i ++) {
btrie_add_prefix (btrie, addrs[i].addr6,
addrs[i].mask6, GSIZE_TO_POINTER (i + 1));
}
- ts2 = rspamd_get_ticks ();
+ ts2 = rspamd_get_ticks (TRUE);
diff = (ts2 - ts1) * 1000.0;
- msg_info ("Added %hz elements in %.6f ms", nelts, diff);
+ msg_info ("Added %hz elements in %.0f ticks", nelts, diff);
- ts1 = rspamd_get_ticks ();
+ ts1 = rspamd_get_ticks (TRUE);
for (lc = 0; lc < lookup_cycles && all_good; lc ++) {
for (i = 0; i < nelts / lookup_divisor; i ++) {
check = ottery_rand_range (nelts - 1);
@@ -272,26 +272,26 @@ rspamd_radix_test_func (void)
}
}
g_assert (all_good);
- ts2 = rspamd_get_ticks ();
+ ts2 = rspamd_get_ticks (TRUE);
diff = (ts2 - ts1) * 1000.0;
- msg_info ("Checked %hz elements in %.6f ms",
+ msg_info ("Checked %hz elements in %.0f ticks",
nelts * lookup_cycles / lookup_divisor, diff);
msg_info ("new radix performance (%z elts)", nelts);
- ts1 = rspamd_get_ticks ();
+ ts1 = rspamd_get_ticks (TRUE);
for (i = 0; i < nelts; i ++) {
radix_insert_compressed (comp_tree, addrs[i].addr6, sizeof (addrs[i].addr6),
128 - addrs[i].mask6, i + 1);
}
- ts2 = rspamd_get_ticks ();
+ ts2 = rspamd_get_ticks (TRUE);
diff = (ts2 - ts1) * 1000.0;
- msg_info ("Added %hz elements in %.6f ms", nelts, diff);
+ msg_info ("Added %hz elements in %.0f ticks", nelts, diff);
- ts1 = rspamd_get_ticks ();
+ ts1 = rspamd_get_ticks (TRUE);
for (lc = 0; lc < lookup_cycles && all_good; lc ++) {
for (i = 0; i < nelts / lookup_divisor; i ++) {
check = ottery_rand_range (nelts - 1);
@@ -324,10 +324,10 @@ rspamd_radix_test_func (void)
#endif
g_assert (all_good);
- ts2 = rspamd_get_ticks ();
+ ts2 = rspamd_get_ticks (TRUE);
diff = (ts2 - ts1) * 1000.0;
- msg_info ("Checked %hz elements in %.6f ms",
+ msg_info ("Checked %hz elements in %.0f ticks",
nelts * lookup_cycles / lookup_divisor, diff);
radix_destroy_compressed (comp_tree);