diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-01-15 05:36:12 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-15 13:36:12 +0000 |
commit | 8f321a8a39b0926e00ff9e76c44bc687f3a3c8da (patch) | |
tree | 18ca86ba6e25dc074f5e8c0d39cf0219997743e4 /ext/webidl/benches/dict.rs | |
parent | a4c98e347215528d20e4891e4f0e54b2d8523c89 (diff) |
chore(ext/webidl): Add dictionary converter microbenchmark (#17435)
This commits add a `webidl.createDictionaryConverter` converter
microbenchmark.
There are 2 PRs currently open that need a microbenchmark for webidl
dictionary converter. See https://github.com/denoland/deno/pull/16594
and https://github.com/denoland/deno/pull/16407
Closes https://github.com/denoland/deno/issues/17436
Diffstat (limited to 'ext/webidl/benches/dict.rs')
-rw-r--r-- | ext/webidl/benches/dict.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/ext/webidl/benches/dict.rs b/ext/webidl/benches/dict.rs new file mode 100644 index 000000000..e7df8af62 --- /dev/null +++ b/ext/webidl/benches/dict.rs @@ -0,0 +1,42 @@ +// 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; + +fn setup() -> Vec<Extension> { + vec![ + deno_webidl::init(), + Extension::builder("deno_webidl_bench") + .js(vec![("setup", 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); |