0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

op_crates/url: basic url_parse bench (#10245)

This commit is contained in:
Aaron O'Mullan 2021-04-19 15:42:59 +02:00 committed by GitHub
parent 167f017ca0
commit 776a999eab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 0 deletions

1
Cargo.lock generated
View file

@ -734,6 +734,7 @@ dependencies = [
name = "deno_url"
version = "0.3.0"
dependencies = [
"bench_util",
"deno_core",
"idna",
"serde",

View file

@ -17,3 +17,10 @@ path = "lib.rs"
deno_core = { version = "0.84.0", path = "../../core" }
idna = "0.2.2"
serde = { version = "1.0.125", features = ["derive"] }
[dev-dependencies]
bench_util = { version = "0.0.0", path = "../../bench_util" }
[[bench]]
name = "url_ops"
harness = false

View file

@ -0,0 +1,29 @@
use deno_core::op_sync;
use deno_core::JsRuntime;
use bench_util::bench_js_sync;
use bench_util::bench_or_profile;
use bench_util::bencher::{benchmark_group, Bencher};
fn setup(rt: &mut JsRuntime) {
rt.register_op("op_url_parse", op_sync(deno_url::op_url_parse));
rt.register_op(
"op_url_parse_search_params",
op_sync(deno_url::op_url_parse_search_params),
);
rt.register_op(
"op_url_stringify_search_params",
op_sync(deno_url::op_url_stringify_search_params),
);
deno_url::init(rt);
rt.execute("setup", "const { URL } = globalThis.__bootstrap.url;")
.unwrap();
}
fn bench_url_parse(b: &mut Bencher) {
bench_js_sync(b, r#"new URL(`http://www.google.com/${i}`);"#, setup);
}
benchmark_group!(benches, bench_url_parse,);
bench_or_profile!(benches);