2023-01-15 08:36:12 -05:00
|
|
|
// 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;
|
2023-02-07 18:21:43 -05:00
|
|
|
use deno_core::ExtensionFileSource;
|
2023-01-15 08:36:12 -05:00
|
|
|
|
|
|
|
fn setup() -> Vec<Extension> {
|
|
|
|
vec![
|
2023-06-13 11:45:06 -04:00
|
|
|
deno_webidl::deno_webidl::init(),
|
2023-01-15 08:36:12 -05:00
|
|
|
Extension::builder("deno_webidl_bench")
|
2023-02-07 18:21:43 -05:00
|
|
|
.esm(vec![ExtensionFileSource {
|
2023-03-18 16:09:13 -04:00
|
|
|
specifier: "ext:deno_webidl_bench/setup.js",
|
2023-06-13 11:45:06 -04:00
|
|
|
code: include_str!("dict.js"),
|
2023-02-07 18:21:43 -05:00
|
|
|
}])
|
2023-05-09 16:53:37 -04:00
|
|
|
.esm_entry_point("ext:deno_webidl_bench/setup.js")
|
2023-01-15 08:36:12 -05:00
|
|
|
.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);
|