diff --git a/cli/bench/console.js b/cli/bench/console.js new file mode 100644 index 0000000000..b1873953c3 --- /dev/null +++ b/cli/bench/console.js @@ -0,0 +1,8 @@ +// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +const count = 100000; + +const start = Date.now(); +for (let i = 0; i < count; i++) console.log("Hello World"); +const elapsed = Date.now() - start; +const rate = Math.floor(count / (elapsed / 1000)); +console.log(`time ${elapsed} ms rate ${rate}`); diff --git a/cli/standalone.rs b/cli/standalone.rs index fa5fffd13b..65a51fde51 100644 --- a/cli/standalone.rs +++ b/cli/standalone.rs @@ -283,6 +283,7 @@ pub async fn run( ts_version: version::TYPESCRIPT.to_string(), unstable: metadata.unstable, user_agent: version::get_user_agent(), + inspect: ps.options.is_inspecting(), }, extensions: ops::cli_exts(ps.clone()), unsafely_ignore_certificate_errors: metadata diff --git a/cli/tests/testdata/event_listener_error_immediate_exit.ts.out b/cli/tests/testdata/event_listener_error_immediate_exit.ts.out index 8f03f71b81..1fb3ce76a4 100644 --- a/cli/tests/testdata/event_listener_error_immediate_exit.ts.out +++ b/cli/tests/testdata/event_listener_error_immediate_exit.ts.out @@ -1,4 +1,5 @@ 1 +queueMicrotask error: Uncaught Error: bar throw new Error("bar"); ^ diff --git a/cli/worker.rs b/cli/worker.rs index 9b505e4f0c..f46c2efce7 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -410,6 +410,7 @@ pub async fn create_main_worker( ts_version: version::TYPESCRIPT.to_string(), unstable: ps.options.unstable(), user_agent: version::get_user_agent(), + inspect: ps.options.is_inspecting(), }, extensions, unsafely_ignore_certificate_errors: ps @@ -515,6 +516,7 @@ fn create_web_worker_callback( ts_version: version::TYPESCRIPT.to_string(), unstable: ps.options.unstable(), user_agent: version::get_user_agent(), + inspect: ps.options.is_inspecting(), }, extensions, unsafely_ignore_certificate_errors: ps diff --git a/runtime/examples/hello_runtime.rs b/runtime/examples/hello_runtime.rs index d941cdd052..de5c2427dc 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 b25022a089..27dc7111a5 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 bce30b88ea..82b6a589e7 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 68f223be55..31e7c43825 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() }