2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2023-01-15 08:36:12 -05:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
fn setup() -> Vec<Extension> {
|
2024-02-04 19:03:14 -05:00
|
|
|
deno_core::extension!(
|
|
|
|
deno_webidl_bench,
|
|
|
|
esm_entry_point = "ext:deno_webidl_bench/setup.js",
|
|
|
|
esm = ["ext:deno_webidl_bench/setup.js" = "benches/dict.js"]
|
|
|
|
);
|
|
|
|
|
2023-01-15 08:36:12 -05:00
|
|
|
vec![
|
2023-06-26 07:54:10 -04:00
|
|
|
deno_webidl::deno_webidl::init_ops_and_esm(),
|
2024-02-04 19:03:14 -05:00
|
|
|
deno_webidl_bench::init_ops_and_esm(),
|
2023-01-15 08:36:12 -05:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|