From 6154188786108b253e8c775f728783e9ffa5293f Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Sat, 17 Sep 2022 15:34:43 +0530 Subject: perf(ext/console): avoid `wrapConsole` when not inspecting (#15931) --- runtime/examples/hello_runtime.rs | 1 + runtime/js/99_main.js | 7 +++++-- runtime/worker.rs | 1 + runtime/worker_bootstrap.rs | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) (limited to 'runtime') diff --git a/runtime/examples/hello_runtime.rs b/runtime/examples/hello_runtime.rs index d941cdd05..de5c2427d 100644 --- a/runtime/examples/hello_runtime.rs +++ b/runtime/examples/hello_runtime.rs @@ -39,6 +39,7 @@ async fn main() -> Result<(), AnyError> { ts_version: "x".to_string(), unstable: false, user_agent: "hello_runtime".to_string(), + inspect: false, }, extensions: vec![], unsafely_ignore_certificate_errors: None, diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index b25022a08..27dc7111a 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -648,6 +648,7 @@ delete Intl.v8BreakIterator; ppid, unstableFlag, cpuCount, + inspectFlag, userAgent: userAgentInfo, } = runtimeOptions; @@ -679,8 +680,10 @@ delete Intl.v8BreakIterator; ObjectDefineProperties(globalThis, mainRuntimeGlobalProperties); ObjectSetPrototypeOf(globalThis, Window.prototype); - const consoleFromDeno = globalThis.console; - wrapConsole(consoleFromDeno, consoleFromV8); + if (inspectFlag) { + const consoleFromDeno = globalThis.console; + wrapConsole(consoleFromDeno, consoleFromV8); + } eventTarget.setEventTargetData(globalThis); diff --git a/runtime/worker.rs b/runtime/worker.rs index bce30b88e..82b6a589e 100644 --- a/runtime/worker.rs +++ b/runtime/worker.rs @@ -511,6 +511,7 @@ mod tests { ts_version: "x".to_string(), unstable: false, user_agent: "x".to_string(), + inspect: false, }, extensions: vec![], unsafely_ignore_certificate_errors: None, diff --git a/runtime/worker_bootstrap.rs b/runtime/worker_bootstrap.rs index 68f223be5..31e7c4382 100644 --- a/runtime/worker_bootstrap.rs +++ b/runtime/worker_bootstrap.rs @@ -21,6 +21,7 @@ pub struct BootstrapOptions { pub ts_version: String, pub unstable: bool, pub user_agent: String, + pub inspect: bool, } impl BootstrapOptions { @@ -44,6 +45,7 @@ impl BootstrapOptions { "target": env!("TARGET"), "v8Version": deno_core::v8_version(), "userAgent": self.user_agent, + "inspectFlag": self.inspect, }); serde_json::to_string_pretty(&payload).unwrap() } -- cgit v1.2.3