From 0a390cfc72d0c5472605327a3d277cdf5dfa9360 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 3 Jul 2018 13:58:49 +0100 Subject: [PATCH] [Minor] Reduce speed test cycles in unit tests --- test/lua/unit/base64.lua | 15 +++++++++------ test/lua/unit/siphash.lua | 14 ++++++++------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/test/lua/unit/base64.lua b/test/lua/unit/base64.lua index 1ed04f6f7..add031a45 100644 --- a/test/lua/unit/base64.lua +++ b/test/lua/unit/base64.lua @@ -114,9 +114,12 @@ vehemence of any carnal pleasure.]] assert_equal(cmp, 0, "fuzz test failed for length: " .. tostring(l)) end end) + + local speed_iters = 10000 + test("Base64 test reference vectors 1K", function() local t1 = ffi.C.rspamd_get_ticks() - local res = ffi.C.base64_test(true, 1000000, 1024) + local res = ffi.C.base64_test(true, speed_iters, 1024) local t2 = ffi.C.rspamd_get_ticks() print("Reference base64 (1K): " .. tostring(t2 - t1) .. " sec") @@ -124,7 +127,7 @@ vehemence of any carnal pleasure.]] end) test("Base64 test optimized vectors 1K", function() local t1 = ffi.C.rspamd_get_ticks() - local res = ffi.C.base64_test(false, 1000000, 1024) + local res = ffi.C.base64_test(false, speed_iters, 1024) local t2 = ffi.C.rspamd_get_ticks() print("Optimized base64 (1K): " .. tostring(t2 - t1) .. " sec") @@ -132,7 +135,7 @@ vehemence of any carnal pleasure.]] end) test("Base64 test reference vectors 512", function() local t1 = ffi.C.rspamd_get_ticks() - local res = ffi.C.base64_test(true, 1000000, 512) + local res = ffi.C.base64_test(true, speed_iters, 512) local t2 = ffi.C.rspamd_get_ticks() print("Reference base64 (512): " .. tostring(t2 - t1) .. " sec") @@ -140,7 +143,7 @@ vehemence of any carnal pleasure.]] end) test("Base64 test optimized vectors 512", function() local t1 = ffi.C.rspamd_get_ticks() - local res = ffi.C.base64_test(false, 1000000, 512) + local res = ffi.C.base64_test(false, speed_iters, 512) local t2 = ffi.C.rspamd_get_ticks() print("Optimized base64 (512): " .. tostring(t2 - t1) .. " sec") @@ -148,7 +151,7 @@ vehemence of any carnal pleasure.]] end) test("Base64 test reference vectors 10K", function() local t1 = ffi.C.rspamd_get_ticks() - local res = ffi.C.base64_test(true, 100000, 10240) + local res = ffi.C.base64_test(true, speed_iters / 100, 10240) local t2 = ffi.C.rspamd_get_ticks() print("Reference base64 (10K): " .. tostring(t2 - t1) .. " sec") @@ -156,7 +159,7 @@ vehemence of any carnal pleasure.]] end) test("Base64 test optimized vectors 10K", function() local t1 = ffi.C.rspamd_get_ticks() - local res = ffi.C.base64_test(false, 100000, 10240) + local res = ffi.C.base64_test(false, speed_iters / 100, 10240) local t2 = ffi.C.rspamd_get_ticks() print("Optimized base64 (10K): " .. tostring(t2 - t1) .. " sec") diff --git a/test/lua/unit/siphash.lua b/test/lua/unit/siphash.lua index 3c92d2581..13f02eaf3 100644 --- a/test/lua/unit/siphash.lua +++ b/test/lua/unit/siphash.lua @@ -11,9 +11,11 @@ context("Siphash check functions", function() ffi.C.rspamd_cryptobox_init() + local speed_iters = 1000 + test("Siphash test reference vectors (1KB)", function() local t1 = ffi.C.rspamd_get_ticks() - local res = ffi.C.siphash24_test(true, 100000, 1024) + local res = ffi.C.siphash24_test(true, speed_iters, 1024) local t2 = ffi.C.rspamd_get_ticks() print("Reference siphash (1KB): " .. tostring(t2 - t1) .. " sec") @@ -21,7 +23,7 @@ context("Siphash check functions", function() end) test("Siphash test optimized vectors (1KB)", function() local t1 = ffi.C.rspamd_get_ticks() - local res = ffi.C.siphash24_test(false, 100000, 1024) + local res = ffi.C.siphash24_test(false, speed_iters, 1024) local t2 = ffi.C.rspamd_get_ticks() print("Optimized siphash (1KB): " .. tostring(t2 - t1) .. " sec") @@ -29,7 +31,7 @@ context("Siphash check functions", function() end) test("Siphash test reference vectors (5B)", function() local t1 = ffi.C.rspamd_get_ticks() - local res = ffi.C.siphash24_test(true, 1000000, 5) + local res = ffi.C.siphash24_test(true, speed_iters, 5) local t2 = ffi.C.rspamd_get_ticks() print("Reference siphash (5B): " .. tostring(t2 - t1) .. " sec") @@ -37,7 +39,7 @@ context("Siphash check functions", function() end) test("Siphash test optimized vectors (5B)", function() local t1 = ffi.C.rspamd_get_ticks() - local res = ffi.C.siphash24_test(false, 1000000, 5) + local res = ffi.C.siphash24_test(false, speed_iters, 5) local t2 = ffi.C.rspamd_get_ticks() print("Optimized siphash (5B): " .. tostring(t2 - t1) .. " sec") @@ -45,7 +47,7 @@ context("Siphash check functions", function() end) test("Siphash test reference vectors (50B)", function() local t1 = ffi.C.rspamd_get_ticks() - local res = ffi.C.siphash24_test(true, 1000000, 50) + local res = ffi.C.siphash24_test(true, speed_iters, 50) local t2 = ffi.C.rspamd_get_ticks() print("Reference siphash (50B): " .. tostring(t2 - t1) .. " sec") @@ -53,7 +55,7 @@ context("Siphash check functions", function() end) test("Siphash test optimized vectors (50B)", function() local t1 = ffi.C.rspamd_get_ticks() - local res = ffi.C.siphash24_test(false, 1000000, 50) + local res = ffi.C.siphash24_test(false, speed_iters, 50) local t2 = ffi.C.rspamd_get_ticks() print("Optimized siphash (50B): " .. tostring(t2 - t1) .. " sec") -- 2.39.5