Remove background thread from callback bench

This commit is contained in:
2025-09-03 12:19:10 -04:00
parent 76193f772c
commit 52b0cb3e6e

View File

@@ -176,29 +176,13 @@ int main() {
return gauge_value.load(std::memory_order_relaxed); return gauge_value.load(std::memory_order_relaxed);
}); });
// Background thread updating callback values
std::atomic<bool> stop_callback{false};
std::latch start_latch{2}; // Background thread + benchmark thread
std::thread callback_updater([&]() {
start_latch.arrive_and_wait(); // Wait for benchmark to start
while (!stop_callback.load()) {
counter_value.fetch_add(1);
gauge_value.store(gauge_value.load() + 1);
}
});
ArenaAllocator arena; ArenaAllocator arena;
start_latch.arrive_and_wait(); // Wait for background thread to be ready
bench.run("render() - with callback metrics", [&]() { bench.run("render() - with callback metrics", [&]() {
auto output = metric::render(arena); auto output = metric::render(arena);
ankerl::nanobench::doNotOptimizeAway(output); ankerl::nanobench::doNotOptimizeAway(output);
arena.reset(); arena.reset();
}); });
stop_callback.store(true);
callback_updater.join();
} }
// Render performance scaling // Render performance scaling