From 4ca7774992f4fc8ea6e77684f4e733a2489fcfaf Mon Sep 17 00:00:00 2001 From: Viktor Govako Date: Thu, 21 Apr 2022 11:48:37 +0300 Subject: [PATCH] [test] Relaxed SmallMap benchmark test. Signed-off-by: Viktor Govako --- base/base_tests/small_set_test.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/base/base_tests/small_set_test.cpp b/base/base_tests/small_set_test.cpp index 9a633ed9eb..6d0382ac4d 100644 --- a/base/base_tests/small_set_test.cpp +++ b/base/base_tests/small_set_test.cpp @@ -78,6 +78,11 @@ UNIT_TEST(SmallSet_Smoke) TEST_EQUAL(set.Size(), std::distance(set.begin(), set.end()), ()); } +bool BenchmarkTimeLessOrNear(uint64_t l, uint64_t r, double relativeTolerance) +{ + return (l < r) || ((l - r) / static_cast(l) < relativeTolerance); +} + #ifndef DEBUG std::vector GenerateIndices(uint32_t min, uint32_t max) { @@ -131,7 +136,8 @@ UNIT_TEST(SmallMap_Benchmark1) } TEST_EQUAL(sum1, sum2, ()); - TEST_LESS(t2, t1, ()); + // At this moment, we have rare t2 > t1 on Linux CI. + TEST(BenchmarkTimeLessOrNear(t2, t1, 0.1), (t2, t1)); LOG(LINFO, ("unordered_map time =", t1, "SmallMap time =", t2)); }