summaryrefslogtreecommitdiff
path: root/bench/bench_window.cpp
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2023-05-30 22:14:40 -0400
committerBenji Dial <benji@benjidial.net>2023-05-30 22:14:40 -0400
commit21d36220c869e4e28d437993a082b12b67a2428f (patch)
tree38240ec9388291a8c089080a175478df3d0f505f /bench/bench_window.cpp
parenta988f6a27db39eac6de698a8d0ad31673c865d41 (diff)
downloadlib94-21d36220c869e4e28d437993a082b12b67a2428f.tar.gz
make hyperspeed not update ui so much
Diffstat (limited to 'bench/bench_window.cpp')
-rw-r--r--bench/bench_window.cpp19
1 files changed, 16 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();
}