From 21d36220c869e4e28d437993a082b12b67a2428f Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Tue, 30 May 2023 22:14:40 -0400 Subject: make hyperspeed not update ui so much --- bench/bench_window.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'bench/bench_window.cpp') diff --git a/bench/bench_window.cpp b/bench/bench_window.cpp index 60d44f3..f1035e0 100644 --- a/bench/bench_window.cpp +++ b/bench/bench_window.cpp @@ -141,6 +141,8 @@ const lib94::warrior *bench_window::do_step() { return result; } +static constexpr std::chrono::nanoseconds min_hyperspeed_ui_update_distance(1000000); + void bench_window::runner_main() { std::chrono::system_clock::time_point last_step = std::chrono::system_clock::now(); @@ -154,10 +156,21 @@ void bench_window::runner_main() { break; core_mutex.unlock(); - runner_update_ui_dispatcher.emit(); - if (!runner_hyperspeed) + + if (runner_hyperspeed) { + std::chrono::system_clock::time_point now = std::chrono::system_clock::now(); + if (now - last_hyperspeed_ui_update >= min_hyperspeed_ui_update_distance) { + last_hyperspeed_ui_update = now; + runner_update_ui_dispatcher.emit(); + } + } + + else { + runner_update_ui_dispatcher.emit(); std::this_thread::sleep_until(last_step + time_between_steps); - last_step = std::chrono::system_clock::now(); + last_step = std::chrono::system_clock::now(); + } + core_mutex.lock(); } -- cgit v1.2.3