Skip to content

Commit 64fe10d

Browse files
committed
Print out total time spent executing a type of work packet
1 parent e750dfe commit 64fe10d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/scheduler/stat.rs

+16
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ impl SchedulerStat {
2828
let sum_logs = logs.sum::<f64>();
2929
(sum_logs / values.len() as f64).exp()
3030
}
31+
3132
fn min(&self, values: &[f64]) -> f64 {
3233
let mut min = values[0];
3334
for v in values {
@@ -37,6 +38,7 @@ impl SchedulerStat {
3738
}
3839
min
3940
}
41+
4042
fn max(&self, values: &[f64]) -> f64 {
4143
let mut max = values[0];
4244
for v in values {
@@ -47,6 +49,10 @@ impl SchedulerStat {
4749
max
4850
}
4951

52+
fn sum(&self, values: &[f64]) -> f64 {
53+
values.iter().sum()
54+
}
55+
5056
pub fn harness_stat(&self) -> HashMap<String, String> {
5157
let mut stat = HashMap::new();
5258
// Work counts
@@ -77,6 +83,16 @@ impl SchedulerStat {
7783
format!("work.{}.time.geomean", self.work_name(n)),
7884
format!("{:.2}", geomean),
7985
);
86+
let sum = self.sum(
87+
&durations
88+
.iter()
89+
.map(|d| d.as_nanos() as f64)
90+
.collect::<Vec<_>>(),
91+
);
92+
stat.insert(
93+
format!("work.{}.time.sum", self.work_name(n)),
94+
format!("{:.2}", sum),
95+
);
8096
}
8197
let durations = total_durations
8298
.iter()

0 commit comments

Comments
 (0)