Finish a cycle of a measured element and store the measurement taken. */
| 254 | |
| 255 | /** Finish a cycle of a measured element and store the measurement taken. */ |
| 256 | PerformanceMeasurer::~PerformanceMeasurer() |
| 257 | { |
| 258 | if (this->elem == PFE_ALLSCRIPTS) { |
| 259 | /* Hack to not record scripts total when no scripts are active */ |
| 260 | bool any_active = _pf_data[PFE_GAMESCRIPT].num_valid > 0; |
| 261 | for (uint e = PFE_AI0; e < PFE_MAX; e++) any_active |= _pf_data[e].num_valid > 0; |
| 262 | if (!any_active) { |
| 263 | PerformanceMeasurer::SetInactive(PFE_ALLSCRIPTS); |
| 264 | return; |
| 265 | } |
| 266 | } |
| 267 | if (this->elem == PFE_SOUND) { |
| 268 | /* PFE_SOUND measurements are made from the mixer thread. |
| 269 | * _pf_data cannot be concurrently accessed from the mixer thread |
| 270 | * and the main thread, so store the measurement results in a |
| 271 | * mutex-protected queue which is drained by the main thread. |
| 272 | * See: ProcessPendingPerformanceMeasurements() */ |
| 273 | TimingMeasurement end = GetPerformanceTimer(); |
| 274 | std::lock_guard lk(_sound_perf_lock); |
| 275 | if (_sound_perf_measurements.size() >= NUM_FRAMERATE_POINTS * 2) return; |
| 276 | _sound_perf_measurements.push_back(this->start_time); |
| 277 | _sound_perf_measurements.push_back(end); |
| 278 | _sound_perf_pending.store(true, std::memory_order_release); |
| 279 | return; |
| 280 | } |
| 281 | _pf_data[this->elem].Add(this->start_time, GetPerformanceTimer()); |
| 282 | } |
| 283 | |
| 284 | /** Set the rate of expected cycles per second of a performance element. */ |
| 285 | void PerformanceMeasurer::SetExpectedRate(double rate) |
nothing calls this directly
no test coverage detected