perf: improve performance.now (#15481)

This commit is contained in:
Ryan Dahl 2022-08-16 11:30:16 -04:00 committed by GitHub
parent eab66a9f4d
commit 0b70c81f97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,8 +33,9 @@ where
TP: TimersPermission + 'static,
{
let start_time = state.borrow::<StartTime>();
let seconds = start_time.elapsed().as_secs();
let mut subsec_nanos = start_time.elapsed().subsec_nanos() as f64;
let elapsed = start_time.elapsed();
let seconds = elapsed.as_secs();
let mut subsec_nanos = elapsed.subsec_nanos() as f64;
let reduced_time_precision = 2_000_000.0; // 2ms in nanoseconds
// If the permission is not enabled