aboutsummaryrefslogtreecommitdiffstats
path: root/test/rspamd_radix_test.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-09-17 17:43:04 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-09-17 17:43:04 +0100
commit7eaf0fbe91ad6d9ffc4eae5cc2c1dc88a953b772 (patch)
treeb39c8d70b7dfe5e54cc69800ea78697607f7f72c /test/rspamd_radix_test.c
parent3747d8d66eafa0298b434cad8f1c0dfd254a9261 (diff)
downloadrspamd-7eaf0fbe91ad6d9ffc4eae5cc2c1dc88a953b772.tar.gz
rspamd-7eaf0fbe91ad6d9ffc4eae5cc2c1dc88a953b772.zip
More realistic workload for radix.
Diffstat (limited to 'test/rspamd_radix_test.c')
-rw-r--r--test/rspamd_radix_test.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/test/rspamd_radix_test.c b/test/rspamd_radix_test.c
index 389e6f523..b0fecd26b 100644
--- a/test/rspamd_radix_test.c
+++ b/test/rspamd_radix_test.c
@@ -26,14 +26,19 @@
#include "radix.h"
#include "ottery.h"
-const gsize max_elts = 1 * 1024 * 1024;
+const gsize max_elts = 20 * 1024;
+const gint lookup_cycles = 1 * 1024;
const uint masks[] = {
8,
16,
24,
32,
- 27
+ 27,
+ 29,
+ 19,
+ 13,
+ 22
};
struct _tv {
@@ -123,6 +128,7 @@ rspamd_radix_test_func (void)
guint32 mask;
} *addrs;
gsize nelts, i;
+ gint lc;
gboolean all_good = TRUE;
struct timespec ts1, ts2;
double diff;
@@ -153,8 +159,10 @@ rspamd_radix_test_func (void)
msg_info ("Added %z elements in %.6f ms", nelts, diff);
clock_gettime (CLOCK_MONOTONIC, &ts1);
- for (i = 0; i < nelts; i ++) {
- g_assert (radix32tree_find (tree, addrs[i].addr) != RADIX_NO_VALUE);
+ for (lc = 0; lc < lookup_cycles; lc ++) {
+ for (i = 0; i < nelts; i ++) {
+ g_assert (radix32tree_find (tree, addrs[i].addr) != RADIX_NO_VALUE);
+ }
}
clock_gettime (CLOCK_MONOTONIC, &ts2);
diff = (ts2.tv_sec - ts1.tv_sec) * 1000. + /* Seconds */
@@ -187,16 +195,18 @@ rspamd_radix_test_func (void)
msg_info ("Added %z elements in %.6f ms", nelts, diff);
clock_gettime (CLOCK_MONOTONIC, &ts1);
- for (i = 0; i < nelts; i ++) {
+ for (lc = 0; lc < lookup_cycles; lc ++) {
+ for (i = 0; i < nelts; i ++) {
#if 0
- /* Used to write bad random vector */
- msg_info("{\"%s\", NULL, \"%ud\", 0, 0, 0, 0},",
- inet_ntoa(*(struct in_addr *)&addrs[i].addr),
- addrs[i].mask);
+ /* Used to write bad random vector */
+ msg_info("{\"%s\", NULL, \"%ud\", 0, 0, 0, 0},",
+ inet_ntoa(*(struct in_addr *)&addrs[i].addr),
+ addrs[i].mask);
#endif
- if (radix_find_compressed (comp_tree, &addrs[i].addr, sizeof (guint32))
- == RADIX_NO_VALUE) {
- all_good = FALSE;
+ if (radix_find_compressed (comp_tree, &addrs[i].addr, sizeof (guint32))
+ == RADIX_NO_VALUE) {
+ all_good = FALSE;
+ }
}
}
g_assert (all_good);