diff --git a/src/bpf_program.rs b/src/bpf_program.rs index 3cce6df..36dfa5e 100644 --- a/src/bpf_program.rs +++ b/src/bpf_program.rs @@ -73,7 +73,7 @@ impl BpfProgram { if self.run_time_ns == 0 { return 0.0; } - (self.runtime_delta() as f64 / self.num_cpus as f64) / self.timestamp_delta() as f64 * 100.0 + self.runtime_delta() as f64 / self.timestamp_delta() as f64 * 100.0 } } @@ -197,8 +197,8 @@ mod tests { timestamp_ns: 2000, num_cpus: 4, }; - // Calculate expected value: ((200 - 100) / 4) / (2000 - 1000) * 100 = 2.5 - let expected = 2.5; + // Calculate expected value: (200 - 100) / (2000 - 1000) * 100 = 10.0 + let expected = 10.0; assert_eq!(prog.cpu_time_percent(), expected); } } diff --git a/src/main.rs b/src/main.rs index 8be01ed..ca83934 100644 --- a/src/main.rs +++ b/src/main.rs @@ -202,7 +202,7 @@ fn ui(f: &mut Frame, app: &mut App) { "Period Avg Runtime (ns)", "Total Avg Runtime (ns)", "Events per second", - "CPU %", + "Total CPU %", ] .iter() .map(|h| Cell::from(*h).style(Style::default()));