summaryrefslogtreecommitdiff
path: root/bench_util/src
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-05-21 15:42:17 +0200
committerGitHub <noreply@github.com>2021-05-21 15:42:17 +0200
commitf82e7d3bdf18cf103d536050e3032494fff10bd8 (patch)
tree19b6ab162e5be8daf719771ba18e3eb135dc1a88 /bench_util/src
parent4a9b40b717dc7e5be59bbd4e56670d27995faf58 (diff)
fix(bench_util): correctly run async benches in tokio context (#10736)
Diffstat (limited to 'bench_util/src')
-rw-r--r--bench_util/src/js_runtime.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/bench_util/src/js_runtime.rs b/bench_util/src/js_runtime.rs
index a19eccd1f..cc704ff97 100644
--- a/bench_util/src/js_runtime.rs
+++ b/bench_util/src/js_runtime.rs
@@ -64,15 +64,16 @@ pub fn bench_js_async(
if is_profiling() {
for _ in 0..10000 {
- runtime.execute("inner_loop", src).unwrap();
- let future = runtime.run_event_loop();
- tokio_runtime.block_on(future).unwrap();
+ tokio_runtime.block_on(inner_async(src, &mut runtime));
}
} else {
b.iter(|| {
- runtime.execute("inner_loop", src).unwrap();
- let future = runtime.run_event_loop();
- tokio_runtime.block_on(future).unwrap();
+ tokio_runtime.block_on(inner_async(src, &mut runtime));
});
}
}
+
+async fn inner_async(src: &str, runtime: &mut JsRuntime) {
+ runtime.execute("inner_loop", src).unwrap();
+ runtime.run_event_loop().await.unwrap();
+}