2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2023-01-13 02:51:32 -05:00
|
|
|
|
2021-05-19 13:41:23 -04:00
|
|
|
use deno_bench_util::bench_js_sync;
|
|
|
|
use deno_bench_util::bench_or_profile;
|
2023-01-14 23:18:58 -05:00
|
|
|
use deno_bench_util::bencher::benchmark_group;
|
|
|
|
use deno_bench_util::bencher::Bencher;
|
2021-04-20 18:15:39 -04:00
|
|
|
|
2021-05-21 09:46:26 -04:00
|
|
|
use deno_core::Extension;
|
2023-02-07 18:21:43 -05:00
|
|
|
use deno_core::ExtensionFileSource;
|
2023-06-13 18:36:16 -04:00
|
|
|
use deno_core::ExtensionFileSourceCode;
|
2021-04-19 09:42:59 -04:00
|
|
|
|
2021-05-21 09:46:26 -04:00
|
|
|
fn setup() -> Vec<Extension> {
|
|
|
|
vec![
|
2023-06-26 07:54:10 -04:00
|
|
|
deno_webidl::deno_webidl::init_ops_and_esm(),
|
2023-11-20 08:01:30 -05:00
|
|
|
deno_console::deno_console::init_ops_and_esm(),
|
2023-06-26 07:54:10 -04:00
|
|
|
deno_url::deno_url::init_ops_and_esm(),
|
2023-07-31 14:19:15 -04:00
|
|
|
Extension {
|
|
|
|
name: "bench_setup",
|
|
|
|
esm_files: std::borrow::Cow::Borrowed(&[ExtensionFileSource {
|
2023-03-18 16:09:13 -04:00
|
|
|
specifier: "ext:bench_setup/setup",
|
2023-06-13 18:36:16 -04:00
|
|
|
code: ExtensionFileSourceCode::IncludedInBinary(
|
2023-07-31 14:19:15 -04:00
|
|
|
r#"
|
|
|
|
import { URL } from "ext:deno_url/00_url.js";
|
|
|
|
globalThis.URL = URL;
|
2023-02-07 14:22:46 -05:00
|
|
|
"#,
|
2023-06-13 18:36:16 -04:00
|
|
|
),
|
2023-07-31 14:19:15 -04:00
|
|
|
}]),
|
|
|
|
esm_entry_point: Some("ext:bench_setup/setup"),
|
|
|
|
..Default::default()
|
|
|
|
},
|
2021-05-21 09:46:26 -04:00
|
|
|
]
|
2021-04-19 09:42:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn bench_url_parse(b: &mut Bencher) {
|
2021-05-19 13:41:23 -04:00
|
|
|
bench_js_sync(b, r#"new URL(`http://www.google.com/`);"#, setup);
|
2021-04-19 09:42:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
benchmark_group!(benches, bench_url_parse,);
|
2021-05-19 13:41:23 -04:00
|
|
|
bench_or_profile!(benches);
|