From 1c9d0810abccd998421636e0c1d1ba4dfe0f790d Mon Sep 17 00:00:00 2001 From: "Zezheng.Li" Date: Fri, 11 Oct 2024 16:54:37 +0800 Subject: [PATCH] [metric] fix test out-of-memory on msvc x86 --- src/metric/benchmark/bench.hpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/metric/benchmark/bench.hpp b/src/metric/benchmark/bench.hpp index 250bf0e6b..ce9e42777 100644 --- a/src/metric/benchmark/bench.hpp +++ b/src/metric/benchmark/bench.hpp @@ -36,11 +36,13 @@ void bench_mixed_impl(IMPL& impl, WRITE_OP&& op, size_t thd_num, std::string val(36, ' '); for (size_t i = 0; i < thd_num; i++) { vec.push_back(std::thread([&, i] { - while (!stop) { - bench_clock_t clock; + bench_clock_t clock_loop; + auto dur = clock.duration(); + while (!stop || dur < duration * 2) { op(); - auto t = clock.duration(); - lantency_summary.observe(t.count() / 1000.0f); + auto new_dur = clock.duration(); + lantency_summary.observe((new_dur - dur).count() / 1000.0f); + dur = new_dur; } })); } @@ -55,6 +57,10 @@ void bench_mixed_impl(IMPL& impl, WRITE_OP&& op, size_t thd_num, } while (clock2.duration() < duration); auto total_ms = clock.duration(); stop = true; + if constexpr (requires { impl.size(); }) { + std::cout << "size:" << impl.size() << "\n"; + } + std::cout << "run " << total_ms.count() << "ms\n"; uint64_t cnt; double sum;