deno/bench_util
Bartek Iwańczuk 204c46dcc1
chore: forward v1.26.2 to main (#16331)
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>

<!--
Before submitting a PR, please read http://deno.land/manual/contributing

1. Give the PR a descriptive title.

  Examples of good title:
    - fix(std/http): Fix race condition in server
    - docs(console): Update docstrings
    - feat(doc): Handle nested reexports

  Examples of bad title:
    - fix #7123
    - update docs
    - fix bugs

2. Ensure there is a related issue and it is referenced in the PR text.
3. Ensure there are tests that cover the changes.
4. Ensure `cargo test` passes.
5. Ensure `./tools/format.js` passes without changing files.
6. Ensure `./tools/lint.js` passes.
-->

Co-authored-by: denobot <33910674+denobot@users.noreply.github.com>
Co-authored-by: bartlomieju <bartlomieju@users.noreply.github.com>
2022-10-17 23:11:16 +02:00
..
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 chore: drop src/ in bench_util & serde_v8 (#14097) 2022-03-24 11:23:40 +01:00
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);