summaryrefslogtreecommitdiff
path: root/cli/js/web/performance.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-03-11 10:53:06 +0100
committerGitHub <noreply@github.com>2020-03-11 10:53:06 +0100
commit99a0c6df79b903e4fe72ce066787039bdede3868 (patch)
tree1c0abdb964a2e052b593dc8fa3e515f76dbc0642 /cli/js/web/performance.ts
parent94f4c6807a34a564f567b984e71e36e9cb9c5005 (diff)
reorg: cli/js/compiler/, move more API to cli/js/web/ (#4310)
- moves compiler implementation to "cli/js/compiler/" directory - moves more APIs to "cli/js/web": * "console.ts" * "console_table.ts" * "performance.ts" * "timers.ts" * "workers.ts" - removes some dead code from "cli/js/"
Diffstat (limited to 'cli/js/web/performance.ts')
-rw-r--r--cli/js/web/performance.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/cli/js/web/performance.ts b/cli/js/web/performance.ts
new file mode 100644
index 000000000..cb4daa846
--- /dev/null
+++ b/cli/js/web/performance.ts
@@ -0,0 +1,16 @@
+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+import { now as opNow } from "../ops/timers.ts";
+
+export class Performance {
+ /** Returns a current time from Deno's start in milliseconds.
+ *
+ * Use the flag --allow-hrtime return a precise value.
+ *
+ * const t = performance.now();
+ * console.log(`${t} ms since start!`);
+ */
+ now(): number {
+ const res = opNow();
+ return res.seconds * 1e3 + res.subsecNanos / 1e6;
+ }
+}