Add check for invalid timer values from the DummyBackend
Needed for systems where the Windows QPC timer returns erratic values
This commit is contained in:
parent
b2a7393553
commit
cf88bbc472
@ -88,6 +88,8 @@ public:
|
||||
private: // methods
|
||||
static uint32_t max_value_history () { return 16; }
|
||||
|
||||
int64_t max_timer_error () { return 4 * m_max_time_us; }
|
||||
|
||||
private: // data
|
||||
int64_t m_max_time_us;
|
||||
int64_t m_start_timestamp_us;
|
||||
|
@ -28,6 +28,19 @@ DSPLoadCalculator::set_stop_timestamp_us(int64_t stop_timestamp_us)
|
||||
// which would mean consistent overhead for small values of m_max_time_us
|
||||
|
||||
m_stop_timestamp_us = stop_timestamp_us;
|
||||
|
||||
/* querying the performance counter can fail occasionally (-1).
|
||||
* Also on some multi-core systems, timers are CPU specific and not
|
||||
* synchronized. We assume they differ more than a few milliseconds
|
||||
* (4 * nominal cycle time) and simply ignore cases where the
|
||||
* execution switches cores.
|
||||
*/
|
||||
if (m_start_timestamp_us < 0 || m_stop_timestamp_us < 0 ||
|
||||
m_start_timestamp_us > m_stop_timestamp_us ||
|
||||
elapsed_time_us() > max_timer_error()) {
|
||||
return;
|
||||
}
|
||||
|
||||
float load = 0;
|
||||
|
||||
if (elapsed_time_us() > m_max_time_us) {
|
||||
|
Loading…
Reference in New Issue
Block a user