@@ -11,27 +11,21 @@ macro_rules! really_warn {
11
11
}
12
12
13
13
pub enum Counter {
14
- Zero ( InstructionsMinusIrqs ) ,
15
- WallTime ( InstructionsMinusIrqs , WallTime ) ,
16
- Instructions ( InstructionsMinusIrqs , Instructions ) ,
14
+ WallTime ( WallTime ) ,
15
+ Instructions ( Instructions ) ,
17
16
InstructionsMinusIrqs ( InstructionsMinusIrqs ) ,
18
17
InstructionsMinusRaw0420 ( InstructionsMinusRaw0420 ) ,
19
18
}
20
19
21
20
impl Counter {
22
21
pub fn by_name ( name : & str ) -> Result < Self , Box < dyn Error + Send + Sync > > {
23
22
Ok ( match name {
24
- "0" => Counter :: Zero ( InstructionsMinusIrqs :: new ( ) ?) ,
25
- "t" | WallTime :: NAME => {
26
- Counter :: WallTime ( InstructionsMinusIrqs :: new ( ) ?, WallTime :: new ( ) )
27
- }
28
- "i" | Instructions :: NAME => {
29
- Counter :: Instructions ( InstructionsMinusIrqs :: new ( ) ?, Instructions :: new ( ) ?)
30
- }
31
- "I" | InstructionsMinusIrqs :: NAME => {
23
+ WallTime :: NAME => Counter :: WallTime ( WallTime :: new ( ) ) ,
24
+ Instructions :: NAME => Counter :: Instructions ( Instructions :: new ( ) ?) ,
25
+ InstructionsMinusIrqs :: NAME => {
32
26
Counter :: InstructionsMinusIrqs ( InstructionsMinusIrqs :: new ( ) ?)
33
27
}
34
- "r" | InstructionsMinusRaw0420 :: NAME => {
28
+ InstructionsMinusRaw0420 :: NAME => {
35
29
Counter :: InstructionsMinusRaw0420 ( InstructionsMinusRaw0420 :: new ( ) ?)
36
30
}
37
31
_ => return Err ( format ! ( "{:?} is not a valid counter name" , name) . into ( ) ) ,
@@ -40,12 +34,11 @@ impl Counter {
40
34
41
35
pub ( super ) fn describe_as_json ( & self ) -> String {
42
36
let ( name, units) = match self {
43
- Counter :: Zero ( _) => ( "zero" , "[]" ) ,
44
- Counter :: WallTime ( ..) => (
37
+ Counter :: WallTime ( _) => (
45
38
WallTime :: NAME ,
46
39
r#"[["ns", 1], ["μs", 1000], ["ms", 1000000], ["s", 1000000000]]"# ,
47
40
) ,
48
- Counter :: Instructions ( .. ) => ( Instructions :: NAME , r#"[["instructions", 1]]"# ) ,
41
+ Counter :: Instructions ( _ ) => ( Instructions :: NAME , r#"[["instructions", 1]]"# ) ,
49
42
Counter :: InstructionsMinusIrqs ( _) => {
50
43
( InstructionsMinusIrqs :: NAME , r#"[["instructions", 1]]"# )
51
44
}
@@ -59,9 +52,8 @@ impl Counter {
59
52
#[ inline]
60
53
pub ( super ) fn since_start ( & self ) -> u64 {
61
54
match self {
62
- Counter :: Zero ( _) => 0 ,
63
- Counter :: WallTime ( _, counter) => counter. since_start ( ) ,
64
- Counter :: Instructions ( _, counter) => counter. since_start ( ) ,
55
+ Counter :: WallTime ( counter) => counter. since_start ( ) ,
56
+ Counter :: Instructions ( counter) => counter. since_start ( ) ,
65
57
Counter :: InstructionsMinusIrqs ( counter) => counter. since_start ( ) ,
66
58
Counter :: InstructionsMinusRaw0420 ( counter) => counter. since_start ( ) ,
67
59
}
@@ -140,17 +132,6 @@ impl InstructionsMinusIrqs {
140
132
}
141
133
}
142
134
143
- // HACK(eddyb) dump total `instructions-minus-irqs:u` for statistics.
144
- impl Drop for InstructionsMinusIrqs {
145
- fn drop ( & mut self ) {
146
- eprintln ! (
147
- "pid={:06} instructions-minus-irqs:u={}" ,
148
- std:: process:: id( ) ,
149
- self . since_start( ) ,
150
- ) ;
151
- }
152
- }
153
-
154
135
// HACK(eddyb) this is a variant of `instructions-minus-irqs:u`, where `r0420`
155
136
// is subtracted, instead of the usual "hardware interrupts" (aka IRQs).
156
137
// `r0420` is an undocumented counter on AMD Zen CPUs which appears to count
0 commit comments