mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
fix(bench_util): correctly run async benches in tokio context (#10736)
This commit is contained in:
parent
4a9b40b717
commit
f82e7d3bdf
1 changed files with 7 additions and 6 deletions
|
@ -64,15 +64,16 @@ pub fn bench_js_async(
|
||||||
|
|
||||||
if is_profiling() {
|
if is_profiling() {
|
||||||
for _ in 0..10000 {
|
for _ in 0..10000 {
|
||||||
runtime.execute("inner_loop", src).unwrap();
|
tokio_runtime.block_on(inner_async(src, &mut runtime));
|
||||||
let future = runtime.run_event_loop();
|
|
||||||
tokio_runtime.block_on(future).unwrap();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
runtime.execute("inner_loop", src).unwrap();
|
tokio_runtime.block_on(inner_async(src, &mut runtime));
|
||||||
let future = runtime.run_event_loop();
|
|
||||||
tokio_runtime.block_on(future).unwrap();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn inner_async(src: &str, runtime: &mut JsRuntime) {
|
||||||
|
runtime.execute("inner_loop", src).unwrap();
|
||||||
|
runtime.run_event_loop().await.unwrap();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue