summaryrefslogtreecommitdiff
path: root/src/core/perf_stats.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/perf_stats.cpp')
-rw-r--r--src/core/perf_stats.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp
index 6635a1339..c9ded49d0 100644
--- a/src/core/perf_stats.cpp
+++ b/src/core/perf_stats.cpp
@@ -127,15 +127,15 @@ double PerfStats::GetLastFrameTimeScale() const {
127 return duration_cast<DoubleSecs>(previous_frame_length).count() / FRAME_LENGTH; 127 return duration_cast<DoubleSecs>(previous_frame_length).count() / FRAME_LENGTH;
128} 128}
129 129
130void FrameLimiter::DoFrameLimiting(microseconds current_system_time_us) { 130void SpeedLimiter::DoSpeedLimiting(microseconds current_system_time_us) {
131 if (!Settings::values.use_frame_limit.GetValue() || 131 if (!Settings::values.use_speed_limit.GetValue() ||
132 Settings::values.use_multi_core.GetValue()) { 132 Settings::values.use_multi_core.GetValue()) {
133 return; 133 return;
134 } 134 }
135 135
136 auto now = Clock::now(); 136 auto now = Clock::now();
137 137
138 const double sleep_scale = Settings::values.frame_limit.GetValue() / 100.0; 138 const double sleep_scale = Settings::values.speed_limit.GetValue() / 100.0;
139 139
140 // Max lag caused by slow frames. Shouldn't be more than the length of a frame at the current 140 // Max lag caused by slow frames. Shouldn't be more than the length of a frame at the current
141 // speed percent or it will clamp too much and prevent this from properly limiting to that 141 // speed percent or it will clamp too much and prevent this from properly limiting to that
@@ -143,17 +143,17 @@ void FrameLimiter::DoFrameLimiting(microseconds current_system_time_us) {
143 // limiting 143 // limiting
144 const microseconds max_lag_time_us = duration_cast<microseconds>( 144 const microseconds max_lag_time_us = duration_cast<microseconds>(
145 std::chrono::duration<double, std::chrono::microseconds::period>(25ms / sleep_scale)); 145 std::chrono::duration<double, std::chrono::microseconds::period>(25ms / sleep_scale));
146 frame_limiting_delta_err += duration_cast<microseconds>( 146 speed_limiting_delta_err += duration_cast<microseconds>(
147 std::chrono::duration<double, std::chrono::microseconds::period>( 147 std::chrono::duration<double, std::chrono::microseconds::period>(
148 (current_system_time_us - previous_system_time_us) / sleep_scale)); 148 (current_system_time_us - previous_system_time_us) / sleep_scale));
149 frame_limiting_delta_err -= duration_cast<microseconds>(now - previous_walltime); 149 speed_limiting_delta_err -= duration_cast<microseconds>(now - previous_walltime);
150 frame_limiting_delta_err = 150 speed_limiting_delta_err =
151 std::clamp(frame_limiting_delta_err, -max_lag_time_us, max_lag_time_us); 151 std::clamp(speed_limiting_delta_err, -max_lag_time_us, max_lag_time_us);
152 152
153 if (frame_limiting_delta_err > microseconds::zero()) { 153 if (speed_limiting_delta_err > microseconds::zero()) {
154 std::this_thread::sleep_for(frame_limiting_delta_err); 154 std::this_thread::sleep_for(speed_limiting_delta_err);
155 auto now_after_sleep = Clock::now(); 155 auto now_after_sleep = Clock::now();
156 frame_limiting_delta_err -= duration_cast<microseconds>(now_after_sleep - now); 156 speed_limiting_delta_err -= duration_cast<microseconds>(now_after_sleep - now);
157 now = now_after_sleep; 157 now = now_after_sleep;
158 } 158 }
159 159