summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bench/bench_window.cpp19
-rw-r--r--bench/bench_window.hpp2
2 files changed, 18 insertions, 3 deletions
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();
}
diff --git a/bench/bench_window.hpp b/bench/bench_window.hpp
index 51e8fbe..ae75e51 100644
--- a/bench/bench_window.hpp
+++ b/bench/bench_window.hpp
@@ -109,6 +109,8 @@ private:
std::thread runner;
bool runner_active;
+ std::chrono::system_clock::time_point last_hyperspeed_ui_update;
+
void update_buttons();
void update_ui();