]> Cypherpunks.ru repositories - gostls13.git/commitdiff
misc/wasm: use NodeJS performance library
authorJohan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Sat, 28 Jan 2023 06:48:57 +0000 (22:48 -0800)
committerJohan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Mon, 30 Jan 2023 18:49:10 +0000 (18:49 +0000)
The upgrade to NodeJS 18 introduces various library
updates that mean we can no longer override the global
performance package. Instead, rely on the performance
library provided by the NodeJS runtime.

Fixes #57516

Change-Id: Ic8ed902c696ad154f676e0b74b42efb84f02f8db
Reviewed-on: https://go-review.googlesource.com/c/go/+/463234
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Evan Phoenix <evan@phx.io>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
misc/wasm/wasm_exec_node.js

index f9200ca95021e93e1305eb9b9521faa3e8acc06b..90905db1150ee7f3e645fe89c59f2a5d954fa152 100644 (file)
@@ -14,12 +14,7 @@ globalThis.fs = require("fs");
 globalThis.TextEncoder = require("util").TextEncoder;
 globalThis.TextDecoder = require("util").TextDecoder;
 
-globalThis.performance = {
-       now() {
-               const [sec, nsec] = process.hrtime();
-               return sec * 1000 + nsec / 1000000;
-       },
-};
+globalThis.performance ??= require("performance");
 
 const crypto = require("crypto");
 globalThis.crypto = {