diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-12-19 10:53:22 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-12-19 10:53:22 +0000 |
commit | 918031c506cd7e229578fdcb11c0289938205813 (patch) | |
tree | 0e04b6f771a7a7c7cc891721dc6d1313622a4194 /test/rspamd_shingles_test.c | |
parent | 47be073a75cc317ebafceaab85bde1009ff93fbc (diff) | |
download | rspamd-918031c506cd7e229578fdcb11c0289938205813.tar.gz rspamd-918031c506cd7e229578fdcb11c0289938205813.zip |
Measure time for shingles generation.
Diffstat (limited to 'test/rspamd_shingles_test.c')
-rw-r--r-- | test/rspamd_shingles_test.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/test/rspamd_shingles_test.c b/test/rspamd_shingles_test.c index 5084cd120..44bc1e789 100644 --- a/test/rspamd_shingles_test.c +++ b/test/rspamd_shingles_test.c @@ -93,18 +93,22 @@ test_case (gsize cnt, gsize max_len, gdouble perm_factor) struct rspamd_shingle *sgl, *sgl_permuted; gdouble res; guchar key[16]; + struct timespec ts1, ts2; ottery_rand_bytes (key, sizeof (key)); input = generate_fuzzy_words (cnt, max_len); + clock_gettime (CLOCK_MONOTONIC, &ts1); sgl = rspamd_shingles_generate (input, key, NULL, rspamd_shingles_default_filter, NULL); + clock_gettime (CLOCK_MONOTONIC, &ts2); permute_vector (input, perm_factor); sgl_permuted = rspamd_shingles_generate (input, key, NULL, rspamd_shingles_default_filter, NULL); res = rspamd_shingles_compare (sgl, sgl_permuted); - msg_debug ("percentage of common shingles: %.3f", res); + msg_debug ("percentage of common shingles: %.3f, generate time: %Hd usec", + res, ts_to_usec (&ts2) - ts_to_usec (&ts1)); g_assert_cmpfloat (fabs ((1.0 - res) - sqrt (perm_factor)), <=, 0.20); free_fuzzy_words (input); @@ -117,8 +121,8 @@ rspamd_shingles_test_func (void) { //test_case (5, 100, 0.5); test_case (200, 10, 0.1); - test_case (500, 100, 0.01); - test_case (5000, 200, 0.01); - test_case (5000, 100, 0); - test_case (5000, 100, 1.0); + test_case (500, 20, 0.01); + test_case (5000, 20, 0.01); + test_case (5000, 15, 0); + test_case (5000, 30, 1.0); } |