2021-05-20 10:45:53 -04:00
|
|
|
# Benching utility for `deno_core` op system
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
```rust
|
2024-01-30 01:58:18 -05:00
|
|
|
use deno_bench_util::bench_js_sync;
|
2021-05-20 10:45:53 -04:00
|
|
|
use deno_bench_util::bench_or_profile;
|
2024-01-30 01:58:18 -05:00
|
|
|
use deno_bench_util::bencher::benchmark_group;
|
|
|
|
use deno_bench_util::bencher::Bencher;
|
2021-05-20 10:45:53 -04:00
|
|
|
|
2021-12-29 08:37:56 -05:00
|
|
|
use deno_core::Extension;
|
2023-07-31 14:19:15 -04:00
|
|
|
|
2023-10-07 11:34:03 -04:00
|
|
|
#[op2]
|
|
|
|
#[number]
|
2023-07-31 14:19:15 -04:00
|
|
|
fn op_nop() -> usize {
|
|
|
|
9
|
|
|
|
}
|
2021-05-20 10:45:53 -04:00
|
|
|
|
2021-12-29 08:37:56 -05:00
|
|
|
fn setup() -> Vec<Extension> {
|
2023-07-31 14:19:15 -04:00
|
|
|
vec![Extension {
|
|
|
|
name: "my_ext"
|
|
|
|
ops: std::borrow::Cow::Borrowed(&[op_nop::DECL])
|
|
|
|
}]
|
2021-05-20 10:45:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn bench_op_nop(b: &mut Bencher) {
|
2022-08-11 09:56:56 -04:00
|
|
|
bench_js_sync(b, r#"Deno.core.ops.op_nop();"#, setup);
|
2021-05-20 10:45:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
benchmark_group!(benches, bench_op_nop);
|
|
|
|
bench_or_profile!(benches);
|
|
|
|
```
|