main: fight jitter

This commit is contained in:
Astro 2019-09-14 02:18:33 +02:00
parent f8dd7d1912
commit 957f92d177
1 changed files with 7 additions and 1 deletions

View File

@ -219,7 +219,13 @@ fn main() -> ! {
}); });
let now = get_time(); let now = get_time();
if now >= last_report + REPORT_INTERVAL { if now >= last_report + REPORT_INTERVAL {
last_report = now; if now < last_report + 2 * REPORT_INTERVAL {
// Try to keep interval constant
last_report += REPORT_INTERVAL;
} else {
// Bad jitter, catch up
last_report = now;
}
// TODO: calculate med instead of avg? // TODO: calculate med instead of avg?
report = Some((now, [ report = Some((now, [
sample[0].0 / (sample[0].1 as u64), sample[0].0 / (sample[0].1 as u64),