Skip to content

Commit ac9a83f

Browse files
committed
Fix test runner CPU usage while running slow solutions
1 parent 1fa327a commit ac9a83f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

crates/aoc/src/cli/mode/test/manager.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,22 @@ impl Manager {
7171
}
7272
if !self.pending_updates.is_empty() && now >= next_update {
7373
self.update_grid(grid)?;
74-
next_update += UPDATE_INTERVAL;
74+
if next_update + UPDATE_INTERVAL < now {
75+
next_update = now + UPDATE_INTERVAL;
76+
} else {
77+
next_update += UPDATE_INTERVAL;
78+
}
7579
}
7680
grid.flush()?;
7781

7882
self.enqueue_processes()?;
7983
self.process_result(
80-
next_spinner_tick
81-
.min(next_update)
82-
.saturating_duration_since(now),
84+
if self.pending_updates.is_empty() {
85+
next_spinner_tick
86+
} else {
87+
next_update.min(next_spinner_tick)
88+
}
89+
.saturating_duration_since(now),
8390
)?;
8491
}
8592

0 commit comments

Comments
 (0)