From 4fc64d5028ee7c8edaa76165d214e2564e1bd90b Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Mon, 17 Jun 2024 20:08:36 +0800 Subject: [PATCH] fix chrono_test --- tile/base/chrono_test.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tile/base/chrono_test.cc b/tile/base/chrono_test.cc index 8df941c..524fbce 100644 --- a/tile/base/chrono_test.cc +++ b/tile/base/chrono_test.cc @@ -5,8 +5,9 @@ namespace tile { static constexpr auto one_ms = std::chrono::milliseconds(1); +static constexpr auto kTestN = 1000; -long AvageTime(std::function f, std::size_t n = 100) { +long AvageTime(std::function f, std::size_t n = kTestN) { long double total = 0; for (std::size_t i = 0; i != n; ++i) { total += 1.0f / n * f(); @@ -34,7 +35,7 @@ TEST(CoarseSystemClock, Compare) { return (ReadCoarseSystemClock() - std::chrono::system_clock::now()) / one_ms; }); - ASSERT_NEAR(diff, 0, 50); + ASSERT_NEAR(diff, 0, kTestN); } TEST(CoarseSteadyClock, Compare) { @@ -42,6 +43,6 @@ TEST(CoarseSteadyClock, Compare) { return (ReadCoarseSteadyClock() - std::chrono::steady_clock::now()) / one_ms; }); - ASSERT_NEAR(diff, 0, 50); + ASSERT_NEAR(diff, 0, kTestN); } } // namespace tile