2021-05-20 10:45:53 -04:00
|
|
|
# Benching utility for `deno_core` op system
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
```rust
|
|
|
|
use deno_bench_util::bench_or_profile;
|
|
|
|
use deno_bench_util::bencher::{benchmark_group, Bencher};
|
|
|
|
use deno_bench_util::bench_js_sync};
|
|
|
|
|
2021-12-29 08:37:56 -05:00
|
|
|
use deno_core::Extension;
|
2023-07-31 14:19:15 -04:00
|
|
|
|
|
|
|
#[op]
|
|
|
|
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);
|
|
|
|
```
|