Skip to content

Commit 136c59f

Browse files
lxsaahCopilot
andcommitted
feat(profiling): optimize avg_time_ns calculation using checked_div
Co-authored-by: Copilot <copilot@github.com>
1 parent 31aba26 commit 136c59f

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

aimdb-core/src/profiling/stage_metrics.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ impl StageMetrics {
5858
/// Mean wall-clock time per invocation, in nanoseconds (0 if no samples).
5959
pub fn avg_time_ns(&self) -> u64 {
6060
let count = self.call_count();
61-
if count == 0 {
62-
0
63-
} else {
64-
self.total_time_ns() / count
65-
}
61+
self.total_time_ns().checked_div(count).unwrap_or(0)
6662
}
6763

6864
/// Fastest recorded invocation, in nanoseconds (0 if no samples).

0 commit comments

Comments
 (0)