Bug 1741355 - GeckoProfiler.CPUUsage: Force some busy work in otherwise idle thread, to ensure there are non-zero CPU values - r=canaltinova

Differential Revision: https://phabricator.services.mozilla.com/D132433
This commit is contained in:
Gerald Squelart 2021-11-30 19:52:31 +00:00
Родитель ca46c4a669
Коммит 70e9daefeb
1 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -4098,6 +4098,13 @@ TEST(GeckoProfiler, CPUUsage)
// Sleep for multiple profiler intervals, so the profiler should have
// samples with zero CPU utilization.
PR_Sleep(PR_MillisecondsToInterval(PROFILER_DEFAULT_INTERVAL * 10));
// Do a busy wait for more than 1ms, to ensure that there are non-zero CPU
// utilization periods.
const TimeStamp target =
TimeStamp::Now() + TimeDuration::FromMilliseconds(2);
while (TimeStamp::Now() < target) {
}
}
});