diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-10-11 11:41:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-11 11:41:54 -0700 |
commit | 97d8498d46bbfb7bb16eeb3a69565d2aeda1e5aa (patch) | |
tree | cfe85f3afccda5c0f87cbb29b79e0eab8d9c0d97 /cli/ops/performance.rs | |
parent | 04ed8d0531b7c2c308b28b742f5c332345d97065 (diff) |
Add init methods for each op module (#3087)
Diffstat (limited to 'cli/ops/performance.rs')
-rw-r--r-- | cli/ops/performance.rs | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/cli/ops/performance.rs b/cli/ops/performance.rs deleted file mode 100644 index 090fc3323..000000000 --- a/cli/ops/performance.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -use super::dispatch_json::{JsonOp, Value}; -use crate::state::ThreadSafeState; -use deno::*; - -// Returns a milliseconds and nanoseconds subsec -// since the start time of the deno runtime. -// If the High precision flag is not set, the -// nanoseconds are rounded on 2ms. -pub fn op_now( - state: &ThreadSafeState, - _args: Value, - _zero_copy: Option<PinnedBuf>, -) -> Result<JsonOp, ErrBox> { - let seconds = state.start_time.elapsed().as_secs(); - let mut subsec_nanos = state.start_time.elapsed().subsec_nanos(); - let reduced_time_precision = 2_000_000; // 2ms in nanoseconds - - // If the permission is not enabled - // Round the nano result on 2 milliseconds - // see: https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp#Reduced_time_precision - if !state.permissions.allows_hrtime() { - subsec_nanos -= subsec_nanos % reduced_time_precision - } - - Ok(JsonOp::Sync(json!({ - "seconds": seconds, - "subsecNanos": subsec_nanos, - }))) -} |