summaryrefslogtreecommitdiff
path: root/js/performance.ts
diff options
context:
space:
mode:
Diffstat (limited to 'js/performance.ts')
-rw-r--r--js/performance.ts12
1 files changed, 4 insertions, 8 deletions
diff --git a/js/performance.ts b/js/performance.ts
index 1af75809b..51e213f0f 100644
--- a/js/performance.ts
+++ b/js/performance.ts
@@ -5,13 +5,9 @@ import * as flatbuffers from "./flatbuffers";
import { assert } from "./util";
export class Performance {
- timeOrigin = 0;
-
- constructor() {
- this.timeOrigin = new Date().getTime();
- }
-
- /** Returns a current time from Deno's start
+ /** Returns a current time from Deno's start.
+ * In milliseconds. Flag --allow-high-precision give
+ * a precise measure.
*
* const t = performance.now();
* console.log(`${t} ms since start!`);
@@ -23,6 +19,6 @@ export class Performance {
assert(msg.Any.NowRes === baseRes.innerType());
const res = new msg.NowRes();
assert(baseRes.inner(res) != null);
- return res.time().toFloat64() - this.timeOrigin;
+ return res.seconds().toFloat64() * 1e3 + res.subsecNanos() / 1e6;
}
}