2021-05-20 14:45:53 +00: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 13:37:56 +00:00
|
|
|
use deno_core::Extension;
|
2023-07-31 18:19:15 +00:00
|
|
|
|
|
|
|
#[op]
|
|
|
|
fn op_nop() -> usize {
|
|
|
|
9
|
|
|
|
}
|
2021-05-20 14:45:53 +00:00
|
|
|
|
2021-12-29 13:37:56 +00:00
|
|
|
fn setup() -> Vec<Extension> {
|
2023-07-31 18:19:15 +00:00
|
|
|
vec![Extension {
|
|
|
|
name: "my_ext"
|
|
|
|
ops: std::borrow::Cow::Borrowed(&[op_nop::DECL])
|
|
|
|
}]
|
2021-05-20 14:45:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn bench_op_nop(b: &mut Bencher) {
|
2022-08-11 13:56:56 +00:00
|
|
|
bench_js_sync(b, r#"Deno.core.ops.op_nop();"#, setup);
|
2021-05-20 14:45:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
benchmark_group!(benches, bench_op_nop);
|
|
|
|
bench_or_profile!(benches);
|
|
|
|
```
|