2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2021-05-22 16:52:05 -04:00
|
|
|
|
2022-08-28 02:51:49 -04:00
|
|
|
use deno_bench_util::bench_js_async;
|
2021-05-22 16:52:05 -04:00
|
|
|
use deno_bench_util::bench_or_profile;
|
2023-01-14 23:18:58 -05:00
|
|
|
use deno_bench_util::bencher::benchmark_group;
|
|
|
|
use deno_bench_util::bencher::Bencher;
|
2023-01-13 02:51:32 -05:00
|
|
|
use deno_core::Extension;
|
2021-05-22 16:52:05 -04:00
|
|
|
|
2023-03-17 14:22:15 -04:00
|
|
|
#[derive(Clone)]
|
2021-10-04 16:56:24 -04:00
|
|
|
struct Permissions;
|
|
|
|
|
2022-02-15 06:17:30 -05:00
|
|
|
impl deno_web::TimersPermission for Permissions {
|
2021-10-04 16:56:24 -04:00
|
|
|
fn allow_hrtime(&mut self) -> bool {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-22 16:52:05 -04:00
|
|
|
fn setup() -> Vec<Extension> {
|
2024-02-04 19:03:14 -05:00
|
|
|
deno_core::extension!(
|
|
|
|
bench_setup,
|
|
|
|
esm_entry_point = "ext:bench_setup/setup",
|
|
|
|
esm = ["ext:bench_setup/setup" = {
|
|
|
|
source = r#"
|
2024-03-01 13:15:18 -05:00
|
|
|
import { setTimeout } from "ext:deno_web/02_timers.js";
|
2024-02-04 19:03:14 -05:00
|
|
|
globalThis.setTimeout = setTimeout;
|
|
|
|
"#
|
|
|
|
}],
|
|
|
|
state = |state| {
|
|
|
|
state.put(Permissions {});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2021-05-22 16:52:05 -04:00
|
|
|
vec![
|
2023-06-26 07:54:10 -04:00
|
|
|
deno_webidl::deno_webidl::init_ops_and_esm(),
|
|
|
|
deno_url::deno_url::init_ops_and_esm(),
|
|
|
|
deno_console::deno_console::init_ops_and_esm(),
|
2023-07-31 14:19:15 -04:00
|
|
|
deno_web::deno_web::init_ops_and_esm::<Permissions>(
|
|
|
|
Default::default(),
|
|
|
|
None,
|
|
|
|
),
|
2024-02-04 19:03:14 -05:00
|
|
|
bench_setup::init_ops_and_esm(),
|
2021-05-22 16:52:05 -04:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
fn bench_set_timeout(b: &mut Bencher) {
|
|
|
|
bench_js_async(b, r#"setTimeout(() => {}, 0);"#, setup);
|
|
|
|
}
|
|
|
|
|
2022-08-28 02:51:49 -04:00
|
|
|
benchmark_group!(benches, bench_set_timeout,);
|
2021-05-22 16:52:05 -04:00
|
|
|
bench_or_profile!(benches);
|