File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -454,21 +454,18 @@ where
454
454
}
455
455
456
456
fn format_timestamp_with_decimals ( & self , start : std:: time:: Instant ) -> String {
457
- let elapsed = start. elapsed ( ) ;
458
- let nanos = elapsed. as_nanos ( ) as f64 ;
459
- let micros = elapsed. as_micros ( ) as f64 ;
460
- let millis = elapsed. as_millis ( ) as f64 ;
457
+ let secs = start. elapsed ( ) . as_secs_f64 ( ) ;
461
458
462
459
// Convert elapsed time to appropriate units: μs, ms, or s.
463
460
// - Less than 1ms: use μs
464
461
// - Less than 1s : use ms
465
462
// - 1s and above : use s
466
- let ( n, unit) = if micros < 1000.0 {
467
- ( nanos / 1000 .0, "μs" )
468
- } else if millis < 1000 .0 {
469
- ( micros / 1000 .0, "ms" )
463
+ let ( n, unit) = if secs < 0.001 {
464
+ ( secs * 1_000_000 .0, "μs" )
465
+ } else if secs < 1 .0 {
466
+ ( secs * 1_000 .0, "ms" )
470
467
} else {
471
- ( millis / 1000.0 , "s " )
468
+ ( secs , "s " )
472
469
} ;
473
470
474
471
let n = format ! ( " {n:.2}" ) ;
You can’t perform that action at this time.
0 commit comments