2021-05-19 19:41:23 +02:00
|
|
|
use deno_bench_util::bench_js_sync;
|
|
|
|
use deno_bench_util::bench_or_profile;
|
|
|
|
use deno_bench_util::bencher::{benchmark_group, Bencher};
|
2021-04-21 00:15:39 +02:00
|
|
|
|
2021-04-19 15:42:59 +02:00
|
|
|
use deno_core::JsRuntime;
|
|
|
|
|
2021-05-19 19:41:23 +02:00
|
|
|
fn setup(runtime: &mut JsRuntime) {
|
|
|
|
// TODO(@AaronO): support caller provided extensions in deno_bench_util
|
|
|
|
let mut ext = deno_url::init();
|
|
|
|
|
|
|
|
for (name, op_fn) in ext.init_ops().unwrap() {
|
|
|
|
runtime.register_op(name, op_fn);
|
|
|
|
}
|
|
|
|
for (filename, src) in ext.init_js() {
|
|
|
|
runtime.execute(filename, src).unwrap();
|
|
|
|
}
|
2021-04-19 15:42:59 +02:00
|
|
|
|
2021-04-21 00:15:39 +02:00
|
|
|
runtime
|
|
|
|
.execute("setup", "const { URL } = globalThis.__bootstrap.url;")
|
2021-04-19 15:42:59 +02:00
|
|
|
.unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|