mirror of
https://github.com/denoland/deno.git
synced 2024-11-27 16:10:57 -05:00
e55b448730
This implements two macros to simplify extension registration and centralize a lot of the boilerplate as a base for future improvements: * `deno_core::ops!` registers a block of `#[op]`s, optionally with type parameters, useful for places where we share lists of ops * `deno_core::extension!` is used to register an extension, and creates two methods that can be used at runtime/snapshot generation time: `init_ops` and `init_ops_and_esm`. --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
49 lines
1.3 KiB
Rust
49 lines
1.3 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::deno_webidl::init_ops_and_esm(),
|
|
Extension::builder("deno_webidl_bench")
|
|
.esm(vec![ExtensionFileSource {
|
|
specifier: "ext: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);
|