mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
perf(ext/console): avoid wrapConsole
when not inspecting (#15931)
This commit is contained in:
parent
fe4b883b73
commit
bfbc5ddc0c
8 changed files with 21 additions and 2 deletions
8
cli/bench/console.js
Normal file
8
cli/bench/console.js
Normal file
|
@ -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}`);
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
1
|
||||
queueMicrotask
|
||||
error: Uncaught Error: bar
|
||||
throw new Error("bar");
|
||||
^
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
||||
if (inspectFlag) {
|
||||
const consoleFromDeno = globalThis.console;
|
||||
wrapConsole(consoleFromDeno, consoleFromV8);
|
||||
}
|
||||
|
||||
eventTarget.setEventTargetData(globalThis);
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue