mirror of
https://github.com/denoland/deno.git
synced 2024-12-01 16:51:13 -05:00
a1cd2a5915
This commit changes definition of "ExtensionFileSource", by changing "code" field to being "ExtensionFileSourceCode" enum. Currently the enum has only a single variant "IncludedInBinary". It is done in preparation to allow embedders to decide if they want to include the source code in the binary when snapshotting (in most cases they shouldn't do that). In the follow up commit we'll add more variants to "ExtensionFileSourceCode". "include_js_files_dir!" macro was removed in favor "include_js_files!" macro which can now accept "dir" option.
49 lines
1.2 KiB
Rust
49 lines
1.2 KiB
Rust
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
|
|
use deno_bench_util::bench_js_sync;
|
|
use deno_bench_util::bench_or_profile;
|
|
use deno_bench_util::bencher::benchmark_group;
|
|
use deno_bench_util::bencher::Bencher;
|
|
|
|
use deno_core::Extension;
|
|
use deno_core::ExtensionFileSource;
|
|
use deno_core::ExtensionFileSourceCode;
|
|
|
|
fn setup() -> Vec<Extension> {
|
|
vec![
|
|
deno_webidl::init(),
|
|
Extension::builder("deno_webidl_bench")
|
|
.esm(vec![ExtensionFileSource {
|
|
specifier: "internal:setup".to_string(),
|
|
code: ExtensionFileSourceCode::IncludedInBinary(include_str!(
|
|
"dict.js"
|
|
)),
|
|
}])
|
|
.build(),
|
|
]
|
|
}
|
|
|
|
fn converter_undefined(b: &mut Bencher) {
|
|
bench_js_sync(b, r#"TextDecodeOptions(undefined);"#, setup);
|
|
}
|
|
|
|
fn handwritten_baseline_undefined(b: &mut Bencher) {
|
|
bench_js_sync(b, r#"handwrittenConverter(undefined)"#, setup);
|
|
}
|
|
|
|
fn converter_object(b: &mut Bencher) {
|
|
bench_js_sync(b, r#"TextDecodeOptions({});"#, setup);
|
|
}
|
|
|
|
fn handwritten_baseline_object(b: &mut Bencher) {
|
|
bench_js_sync(b, r#"handwrittenConverter({})"#, setup);
|
|
}
|
|
|
|
benchmark_group!(
|
|
benches,
|
|
converter_undefined,
|
|
handwritten_baseline_undefined,
|
|
converter_object,
|
|
handwritten_baseline_object,
|
|
);
|
|
bench_or_profile!(benches);
|