0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-31 09:14:20 -04:00
denoland-deno/ext/url/benches/url_ops.rs
Bartek Iwańczuk 8f207c0f3f
refactor: Split extension registration for runtime and snapshotting (#18095)
This commit splits "<ext_name>::init" functions into "init_ops" and
"init_ops_and_esm". That way we don't have to construct list of
ESM sources on each startup if we're running with a snapshot.

In a follow up commit "deno_core" will be changed to not have a split
between "extensions" and "extensions_with_js" - it will be embedders'
responsibility to pass appropriately configured extensions.

Prerequisite for https://github.com/denoland/deno/pull/18080
2023-03-09 14:56:19 +00:00

34 lines
947 B
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_esm(),
deno_url::init_ops_and_esm(),
Extension::builder("bench_setup")
.esm(vec![ExtensionFileSource {
specifier: "ext:setup".to_string(),
code: ExtensionFileSourceCode::IncludedInBinary(
r#"import { URL } from "ext:deno_url/00_url.js";
globalThis.URL = URL;
"#,
),
}])
.build(),
]
}
fn bench_url_parse(b: &mut Bencher) {
bench_js_sync(b, r#"new URL(`http://www.google.com/`);"#, setup);
}
benchmark_group!(benches, bench_url_parse,);
bench_or_profile!(benches);