diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-04-19 15:42:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-19 15:42:59 +0200 |
commit | 776a999eab2b04385ccd2c80cdce365feec20e05 (patch) | |
tree | 8d413c8a7c5f6ad10419fc30f1645addf6f1c0df /op_crates/url/benches/url_ops.rs | |
parent | 167f017ca0a09417325c4f20d8ae08d9f6092e4b (diff) |
op_crates/url: basic url_parse bench (#10245)
Diffstat (limited to 'op_crates/url/benches/url_ops.rs')
-rw-r--r-- | op_crates/url/benches/url_ops.rs | 29 |
1 files changed, 29 insertions, 0 deletions
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); |