0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-31 09:14:20 -04:00
denoland-deno/bench_util
Bartek Iwańczuk e5beb800c9
refactor: move JsRuntimeInspector to deno_core (#10763)
This commit moves implementation of "JsRuntimeInspector" to "deno_core" crate.

To achieve that following changes were made:

* "Worker" and "WebWorker" no longer own instance of "JsRuntimeInspector",
instead it is now owned by "deno_core::JsRuntime".

* Consequently polling of inspector is no longer done in "Worker"/"WebWorker",
instead it's done in "deno_core::JsRuntime::poll_event_loop".

* "deno_core::JsRuntime::poll_event_loop" and "deno_core::JsRuntime::run_event_loop",
now accept "wait_for_inspector" boolean that tells if event loop should still be 
"pending" if there are active inspector sessions - this change fixes the problem 
that inspector disconnects from the frontend and process exits once the code has
stopped executing.
2021-05-26 21:07:12 +02:00
..
benches cleanup(bench_util): use Extensions for setup (#10737) 2021-05-21 15:46:26 +02:00
src refactor: move JsRuntimeInspector to deno_core (#10763) 2021-05-26 21:07:12 +02:00
Cargo.toml chore: publish deno_bench_util crate (#10709) 2021-05-19 21:23:49 +02:00
README.md chore: add README to bench_util/ (#10712) 2021-05-20 16:45:53 +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::JsRuntime;
use deno_core::Op;
use deno_core::OpState;

fn setup(runtime: &mut JsRuntime) {
  runtime.register_op("nop", |state, _| {
    Op::Sync(serialize_op_result(Ok(9), state))
  });
  runtime.sync_ops_cache();
}

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

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