mirror of
https://github.com/denoland/deno.git
synced 2024-12-27 01:29:14 -05:00
cd61c01545
Remove `ExtensionFileSourceCode::LoadedFromFsDuringSnapshot` and feature `include_js_for_snapshotting` since they leak paths that are only applicable in this repo to embedders. Replace with feature `exclude_js_sources`. Additionally the feature `force_include_js_sources` allows negating it, if both features are set. We need both of these because features are additive and there must be a way of force including sources for snapshot creation while still having the `exclude_js_sources` feature. `force_include_js_sources` is only set for build deps, so sources are still excluded from the final binary. You can also specify `force_include_js_sources` on any extension to override the above features for that extension. Towards #19398. But there was still the snapshot-from-snapshot situation where code could be executed twice, I addressed that by making `mod_evaluate()` and scripts like `core/01_core.js` behave idempotently. This allowed unifying `ext::init_ops()` and `ext::init_ops_and_esm()` into `ext::init()`.
60 lines
1.2 KiB
Rust
60 lines
1.2 KiB
Rust
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
|
|
use deno_bench_util::bench_js_async;
|
|
use deno_bench_util::bench_js_sync;
|
|
use deno_bench_util::bench_or_profile;
|
|
use deno_bench_util::bencher::benchmark_group;
|
|
use deno_bench_util::bencher::Bencher;
|
|
|
|
use deno_core::op;
|
|
use deno_core::Extension;
|
|
|
|
deno_core::extension!(
|
|
bench_setup,
|
|
ops = [
|
|
// op_pi_json,
|
|
op_pi_async,
|
|
op_nop
|
|
]
|
|
);
|
|
|
|
fn setup() -> Vec<Extension> {
|
|
vec![bench_setup::init()]
|
|
}
|
|
|
|
#[op]
|
|
fn op_nop() {}
|
|
|
|
// TODO(bartlomieju): reenable, currently this op generates a fast function,
|
|
// which is wrong, because i64 is not a compatible type for fast call.
|
|
// #[op]
|
|
// fn op_pi_json() -> i64 {
|
|
// 314159
|
|
// }
|
|
|
|
// this is a function since async closures aren't stable
|
|
#[op]
|
|
async fn op_pi_async() -> i64 {
|
|
314159
|
|
}
|
|
|
|
// fn bench_op_pi_json(b: &mut Bencher) {
|
|
// bench_js_sync(b, r#"Deno.core.ops.op_pi_json();"#, setup);
|
|
// }
|
|
|
|
fn bench_op_nop(b: &mut Bencher) {
|
|
bench_js_sync(b, r#"Deno.core.ops.op_nop();"#, setup);
|
|
}
|
|
|
|
fn bench_op_async(b: &mut Bencher) {
|
|
bench_js_async(b, r#"Deno.core.opAsync("op_pi_async");"#, setup);
|
|
}
|
|
|
|
benchmark_group!(
|
|
benches,
|
|
// bench_op_pi_json,
|
|
bench_op_nop,
|
|
bench_op_async,
|
|
);
|
|
|
|
bench_or_profile!(benches);
|