From 137f33733d365026903d40e7cde6e34ac6c36dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sat, 24 Aug 2019 17:31:14 +0200 Subject: port more ops to JSON (#2809) --- js/performance.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'js/performance.ts') diff --git a/js/performance.ts b/js/performance.ts index 7aaa7ae45..d2f339c46 100644 --- a/js/performance.ts +++ b/js/performance.ts @@ -1,6 +1,11 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers"; -import { assert } from "./util"; +import * as dispatch from "./dispatch"; +import { sendSync } from "./dispatch_json"; + +interface NowResponse { + seconds: number; + subsecNanos: number; +} export class Performance { /** Returns a current time from Deno's start in milliseconds. @@ -11,12 +16,7 @@ export class Performance { * console.log(`${t} ms since start!`); */ now(): number { - 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; + const res = sendSync(dispatch.OP_NOW) as NowResponse; + return res.seconds * 1e3 + res.subsecNanos / 1e6; } } -- cgit v1.2.3