diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-08-24 13:20:48 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-24 13:20:48 -0700 |
commit | 2235dd795d3cc6c24ff1bdd1bbdcd110b4b0bdfc (patch) | |
tree | a5811adc062cbb1c66f05c863c9be245cf4fd2d2 /js/performance.ts | |
parent | bdc0a13261deaa3748f51d9948b4e7b92864c324 (diff) |
Revert json ops (#2814)
* Revert "port more ops to JSON (#2809)"
This reverts commit 137f33733d365026903d40e7cde6e34ac6c36dcf.
* Revert "port ops to JSON: compiler, errors, fetch, files (#2804)"
This reverts commit 79f82cf10ed1dbf91346994250d7311a4d74377a.
* Revert "Port rest of os ops to JSON (#2802)"
This reverts commit 5b2baa5c990fbeae747e952c5dcd7a5369e950b1.
Diffstat (limited to 'js/performance.ts')
-rw-r--r-- | js/performance.ts | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/js/performance.ts b/js/performance.ts index d2f339c46..7aaa7ae45 100644 --- a/js/performance.ts +++ b/js/performance.ts @@ -1,11 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import * as dispatch from "./dispatch"; -import { sendSync } from "./dispatch_json"; - -interface NowResponse { - seconds: number; - subsecNanos: number; -} +import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers"; +import { assert } from "./util"; export class Performance { /** Returns a current time from Deno's start in milliseconds. @@ -16,7 +11,12 @@ export class Performance { * console.log(`${t} ms since start!`); */ now(): number { - const res = sendSync(dispatch.OP_NOW) as NowResponse; - return res.seconds * 1e3 + res.subsecNanos / 1e6; + const builder = flatbuffers.createBuilder(); + const inner = msg.Now.createNow(builder); + const baseRes = sendSync(builder, msg.Any.Now, inner)!; + assert(msg.Any.NowRes === baseRes.innerType()); + const res = new msg.NowRes(); + assert(baseRes.inner(res) != null); + return res.seconds().toFloat64() * 1e3 + res.subsecNanos() / 1e6; } } |