File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -944,9 +944,12 @@ where
944944 let mut extensions = span. extensions_mut ( ) ;
945945
946946 if let Some ( timings) = extensions. get_mut :: < Timings > ( ) {
947- let now = Instant :: now ( ) ;
948- timings. idle += ( now - timings. last ) . as_nanos ( ) as i64 ;
949- timings. last = now;
947+ if timings. entered_count == 0 {
948+ let now = Instant :: now ( ) ;
949+ timings. idle += ( now - timings. last ) . as_nanos ( ) as i64 ;
950+ timings. last = now;
951+ }
952+ timings. entered_count += 1 ;
950953 }
951954 }
952955
@@ -963,9 +966,12 @@ where
963966 }
964967
965968 if let Some ( timings) = extensions. get_mut :: < Timings > ( ) {
966- let now = Instant :: now ( ) ;
967- timings. busy += ( now - timings. last ) . as_nanos ( ) as i64 ;
968- timings. last = now;
969+ timings. entered_count -= 1 ;
970+ if timings. entered_count == 0 {
971+ let now = Instant :: now ( ) ;
972+ timings. busy += ( now - timings. last ) . as_nanos ( ) as i64 ;
973+ timings. last = now;
974+ }
969975 }
970976 }
971977
@@ -1192,6 +1198,7 @@ struct Timings {
11921198 idle : i64 ,
11931199 busy : i64 ,
11941200 last : Instant ,
1201+ entered_count : u64 ,
11951202}
11961203
11971204impl Timings {
@@ -1200,6 +1207,7 @@ impl Timings {
12001207 idle : 0 ,
12011208 busy : 0 ,
12021209 last : Instant :: now ( ) ,
1210+ entered_count : 0 ,
12031211 }
12041212 }
12051213}
You can’t perform that action at this time.
0 commit comments