deno/bench_util
Divy Srivastava 02187966c1
perf(core): generate inlined wrappers for async ops (#16428)
V8's JIT can do a better job knowing the argument count and also enable
fast call path (in future).

This also lets us call async ops without `opAsync`:

```js
const { ops } = Deno.core;
await ops.op_void_async();
```

this patch: 4405286 ops/sec
main: 3508771 ops/sec
2022-10-27 19:10:48 +05:30
..
benches perf: use fast api for core.isProxy (#15682) 2022-08-30 14:31:36 +05:30
Cargo.toml chore: forward v1.26.2 to main (#16331) 2022-10-17 23:11:16 +02:00
js_runtime.rs perf(core): generate inlined wrappers for async ops (#16428) 2022-10-27 19:10:48 +05:30
lib.rs chore: drop src/ in bench_util & serde_v8 (#14097) 2022-03-24 11:23:40 +01:00
profiling.rs chore: drop src/ in bench_util & serde_v8 (#14097) 2022-03-24 11:23:40 +01:00
README.md perf(ops): Monomorphic sync op calls (#15337) 2022-08-11 15:56:56 +02:00

Benching utility for deno_core op system

Example:

use deno_bench_util::bench_or_profile;
use deno_bench_util::bencher::{benchmark_group, Bencher};
use deno_bench_util::bench_js_sync};

use deno_core::op_sync;
use deno_core::serialize_op_result;
use deno_core::Extension;
use deno_core::JsRuntime;
use deno_core::Op;
use deno_core::OpState;

fn setup() -> Vec<Extension> {
  let custom_ext = Extension::builder()
    .ops(vec![
      ("op_nop", |state, _| {
        Op::Sync(serialize_op_result(Ok(9), state))
      }),
    ])
    .build();
  
  vec![
    // deno_{ext}::init(...),
    custom_ext,
  ]
}

fn bench_op_nop(b: &mut Bencher) {
  bench_js_sync(b, r#"Deno.core.ops.op_nop();"#, setup);
}

benchmark_group!(benches, bench_op_nop);
bench_or_profile!(benches);