mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 08:09:08 -05:00
perf(ext/console): avoid wrapConsole
when not inspecting (#15931)
This commit is contained in:
parent
e7934432ce
commit
6154188786
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(),
|
ts_version: version::TYPESCRIPT.to_string(),
|
||||||
unstable: metadata.unstable,
|
unstable: metadata.unstable,
|
||||||
user_agent: version::get_user_agent(),
|
user_agent: version::get_user_agent(),
|
||||||
|
inspect: ps.options.is_inspecting(),
|
||||||
},
|
},
|
||||||
extensions: ops::cli_exts(ps.clone()),
|
extensions: ops::cli_exts(ps.clone()),
|
||||||
unsafely_ignore_certificate_errors: metadata
|
unsafely_ignore_certificate_errors: metadata
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
1
|
1
|
||||||
|
queueMicrotask
|
||||||
error: Uncaught Error: bar
|
error: Uncaught Error: bar
|
||||||
throw new Error("bar");
|
throw new Error("bar");
|
||||||
^
|
^
|
||||||
|
|
|
@ -410,6 +410,7 @@ pub async fn create_main_worker(
|
||||||
ts_version: version::TYPESCRIPT.to_string(),
|
ts_version: version::TYPESCRIPT.to_string(),
|
||||||
unstable: ps.options.unstable(),
|
unstable: ps.options.unstable(),
|
||||||
user_agent: version::get_user_agent(),
|
user_agent: version::get_user_agent(),
|
||||||
|
inspect: ps.options.is_inspecting(),
|
||||||
},
|
},
|
||||||
extensions,
|
extensions,
|
||||||
unsafely_ignore_certificate_errors: ps
|
unsafely_ignore_certificate_errors: ps
|
||||||
|
@ -515,6 +516,7 @@ fn create_web_worker_callback(
|
||||||
ts_version: version::TYPESCRIPT.to_string(),
|
ts_version: version::TYPESCRIPT.to_string(),
|
||||||
unstable: ps.options.unstable(),
|
unstable: ps.options.unstable(),
|
||||||
user_agent: version::get_user_agent(),
|
user_agent: version::get_user_agent(),
|
||||||
|
inspect: ps.options.is_inspecting(),
|
||||||
},
|
},
|
||||||
extensions,
|
extensions,
|
||||||
unsafely_ignore_certificate_errors: ps
|
unsafely_ignore_certificate_errors: ps
|
||||||
|
|
|
@ -39,6 +39,7 @@ async fn main() -> Result<(), AnyError> {
|
||||||
ts_version: "x".to_string(),
|
ts_version: "x".to_string(),
|
||||||
unstable: false,
|
unstable: false,
|
||||||
user_agent: "hello_runtime".to_string(),
|
user_agent: "hello_runtime".to_string(),
|
||||||
|
inspect: false,
|
||||||
},
|
},
|
||||||
extensions: vec![],
|
extensions: vec![],
|
||||||
unsafely_ignore_certificate_errors: None,
|
unsafely_ignore_certificate_errors: None,
|
||||||
|
|
|
@ -648,6 +648,7 @@ delete Intl.v8BreakIterator;
|
||||||
ppid,
|
ppid,
|
||||||
unstableFlag,
|
unstableFlag,
|
||||||
cpuCount,
|
cpuCount,
|
||||||
|
inspectFlag,
|
||||||
userAgent: userAgentInfo,
|
userAgent: userAgentInfo,
|
||||||
} = runtimeOptions;
|
} = runtimeOptions;
|
||||||
|
|
||||||
|
@ -679,8 +680,10 @@ delete Intl.v8BreakIterator;
|
||||||
ObjectDefineProperties(globalThis, mainRuntimeGlobalProperties);
|
ObjectDefineProperties(globalThis, mainRuntimeGlobalProperties);
|
||||||
ObjectSetPrototypeOf(globalThis, Window.prototype);
|
ObjectSetPrototypeOf(globalThis, Window.prototype);
|
||||||
|
|
||||||
const consoleFromDeno = globalThis.console;
|
if (inspectFlag) {
|
||||||
wrapConsole(consoleFromDeno, consoleFromV8);
|
const consoleFromDeno = globalThis.console;
|
||||||
|
wrapConsole(consoleFromDeno, consoleFromV8);
|
||||||
|
}
|
||||||
|
|
||||||
eventTarget.setEventTargetData(globalThis);
|
eventTarget.setEventTargetData(globalThis);
|
||||||
|
|
||||||
|
|
|
@ -511,6 +511,7 @@ mod tests {
|
||||||
ts_version: "x".to_string(),
|
ts_version: "x".to_string(),
|
||||||
unstable: false,
|
unstable: false,
|
||||||
user_agent: "x".to_string(),
|
user_agent: "x".to_string(),
|
||||||
|
inspect: false,
|
||||||
},
|
},
|
||||||
extensions: vec![],
|
extensions: vec![],
|
||||||
unsafely_ignore_certificate_errors: None,
|
unsafely_ignore_certificate_errors: None,
|
||||||
|
|
|
@ -21,6 +21,7 @@ pub struct BootstrapOptions {
|
||||||
pub ts_version: String,
|
pub ts_version: String,
|
||||||
pub unstable: bool,
|
pub unstable: bool,
|
||||||
pub user_agent: String,
|
pub user_agent: String,
|
||||||
|
pub inspect: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BootstrapOptions {
|
impl BootstrapOptions {
|
||||||
|
@ -44,6 +45,7 @@ impl BootstrapOptions {
|
||||||
"target": env!("TARGET"),
|
"target": env!("TARGET"),
|
||||||
"v8Version": deno_core::v8_version(),
|
"v8Version": deno_core::v8_version(),
|
||||||
"userAgent": self.user_agent,
|
"userAgent": self.user_agent,
|
||||||
|
"inspectFlag": self.inspect,
|
||||||
});
|
});
|
||||||
serde_json::to_string_pretty(&payload).unwrap()
|
serde_json::to_string_pretty(&payload).unwrap()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue