2023-01-13 15:51:32 +08:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
2021-05-19 19:41:23 +02:00
|
|
|
use deno_bench_util::bench_js_sync;
|
|
|
|
use deno_bench_util::bench_or_profile;
|
2023-01-14 20:18:58 -08:00
|
|
|
use deno_bench_util::bencher::benchmark_group;
|
|
|
|
use deno_bench_util::bencher::Bencher;
|
2021-04-21 00:15:39 +02:00
|
|
|
|
2021-05-21 15:46:26 +02:00
|
|
|
use deno_core::Extension;
|
2023-02-08 00:21:43 +01:00
|
|
|
use deno_core::ExtensionFileSource;
|
2023-02-20 01:11:56 +01:00
|
|
|
use deno_core::ExtensionFileSourceCode;
|
2021-04-19 15:42:59 +02:00
|
|
|
|
2021-05-21 15:46:26 +02:00
|
|
|
fn setup() -> Vec<Extension> {
|
|
|
|
vec![
|
2021-06-16 18:40:35 +02:00
|
|
|
deno_webidl::init(),
|
2021-05-21 15:46:26 +02:00
|
|
|
deno_url::init(),
|
2023-01-08 23:48:46 +01:00
|
|
|
Extension::builder("bench_setup")
|
2023-02-08 00:21:43 +01:00
|
|
|
.esm(vec![ExtensionFileSource {
|
|
|
|
specifier: "internal:setup".to_string(),
|
2023-02-20 01:11:56 +01:00
|
|
|
code: ExtensionFileSourceCode::IncludedInBinary(
|
|
|
|
r#"import { URL } from "internal:deno_url/00_url.js";
|
2023-02-07 20:22:46 +01:00
|
|
|
globalThis.URL = URL;
|
|
|
|
"#,
|
2023-02-20 01:11:56 +01:00
|
|
|
),
|
2023-02-08 00:21:43 +01:00
|
|
|
}])
|
2021-05-21 15:46:26 +02:00
|
|
|
.build(),
|
|
|
|
]
|
2021-04-19 15:42:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fn bench_url_parse(b: &mut Bencher) {
|
2021-05-19 19:41:23 +02:00
|
|
|
bench_js_sync(b, r#"new URL(`http://www.google.com/`);"#, setup);
|
2021-04-19 15:42:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
benchmark_group!(benches, bench_url_parse,);
|
2021-05-19 19:41:23 +02:00
|
|
|
bench_or_profile!(benches);
|