summaryrefslogtreecommitdiff
path: root/op_crates
diff options
context:
space:
mode:
Diffstat (limited to 'op_crates')
-rw-r--r--op_crates/url/Cargo.toml7
-rw-r--r--op_crates/url/benches/url_ops.rs29
2 files changed, 36 insertions, 0 deletions
diff --git a/op_crates/url/Cargo.toml b/op_crates/url/Cargo.toml
index a6d48857c..2170aa750 100644
--- a/op_crates/url/Cargo.toml
+++ b/op_crates/url/Cargo.toml
@@ -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
diff --git a/op_crates/url/benches/url_ops.rs b/op_crates/url/benches/url_ops.rs
new file mode 100644
index 000000000..fc2742fbd
--- /dev/null
+++ b/op_crates/url/benches/url_ops.rs
@@ -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);