Skip to content

Commit def781c

Browse files
committed
Don't insert counters when stat is disabled
1 parent e92c562 commit def781c

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/scheduler/stat.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,13 @@ impl WorkerLocalStat {
148148
type_id: work_id,
149149
type_name: work_name,
150150
};
151-
self.work_counters
152-
.entry(work_id)
153-
.or_insert_with(WorkerLocalStat::counter_set)
154-
.iter_mut()
155-
.for_each(|c| c.start());
151+
if self.is_enabled() {
152+
self.work_counters
153+
.entry(work_id)
154+
.or_insert_with(WorkerLocalStat::counter_set)
155+
.iter_mut()
156+
.for_each(|c| c.start());
157+
}
156158
stat
157159
}
158160

src/scheduler/work_counter.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::time::SystemTime;
22

3-
#[derive(Copy, Clone)]
3+
#[derive(Copy, Clone, Debug)]
44
pub(super) struct WorkCounterBase {
55
pub(super) total: f64,
66
pub(super) min: f64,
@@ -17,7 +17,7 @@ impl<T: 'static + WorkCounter + Clone> WorkCounterClone for T {
1717
}
1818
}
1919

20-
pub(super) trait WorkCounter: WorkCounterClone {
20+
pub(super) trait WorkCounter: WorkCounterClone + std::fmt::Debug {
2121
// TODO: consolidate with crate::util::statistics::counter::Counter;
2222
fn start(&mut self);
2323
fn stop(&mut self);
@@ -63,7 +63,7 @@ impl WorkCounterBase {
6363
}
6464
}
6565

66-
#[derive(Copy, Clone)]
66+
#[derive(Copy, Clone, Debug)]
6767
pub(super) struct WorkDuration {
6868
base: WorkCounterBase,
6969
start_value: Option<SystemTime>,

0 commit comments

Comments
 (0)