Skip to content

Commit

Permalink
[metric] fix test out-of-memory on msvc x86
Browse files Browse the repository at this point in the history
  • Loading branch information
poor-circle committed Oct 11, 2024
1 parent 61063f8 commit 1c9d081
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/metric/benchmark/bench.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::chrono::microseconds>();
while (!stop || dur < duration * 2) {
op();
auto t = clock.duration<std::chrono::microseconds>();
lantency_summary.observe(t.count() / 1000.0f);
auto new_dur = clock.duration<std::chrono::microseconds>();
lantency_summary.observe((new_dur - dur).count() / 1000.0f);
dur = new_dur;
}
}));
}
Expand All @@ -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;
Expand Down

0 comments on commit 1c9d081

Please sign in to comment.