MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / bench_instance

Function bench_instance

benches/call.rs:388–426  ·  view source on GitHub ↗

Given a specific instance executes all of the "runner functions"

(
        group: &mut BenchmarkGroup<'_, WallTime>,
        store: &mut Store<()>,
        instance: &Instance,
        desc: &str,
        is_async: IsAsync,
    )

Source from the content-addressed store, hash-verified

386
387 // Given a specific instance executes all of the "runner functions"
388 fn bench_instance(
389 group: &mut BenchmarkGroup<'_, WallTime>,
390 store: &mut Store<()>,
391 instance: &Instance,
392 desc: &str,
393 is_async: IsAsync,
394 ) {
395 group.bench_function(&format!("core - wasm-to-host - {desc} - nop"), |b| {
396 let run = instance
397 .get_typed_func::<u64, ()>(&mut *store, "run-nop")
398 .unwrap();
399 b.iter_custom(|iters| {
400 let start = Instant::now();
401 if is_async.use_async() {
402 run_await(run.call_async(&mut *store, iters)).unwrap();
403 } else {
404 run.call(&mut *store, iters).unwrap();
405 }
406 start.elapsed()
407 })
408 });
409 group.bench_function(
410 &format!("core - wasm-to-host - {desc} - nop-params-and-results"),
411 |b| {
412 let run = instance
413 .get_typed_func::<u64, ()>(&mut *store, "run-nop-params-and-results")
414 .unwrap();
415 b.iter_custom(|iters| {
416 let start = Instant::now();
417 if is_async.use_async() {
418 run_await(run.call_async(&mut *store, iters)).unwrap();
419 } else {
420 run.call(&mut *store, iters).unwrap();
421 }
422 start.elapsed()
423 })
424 },
425 );
426 }
427}
428
429fn assert_vals_eq(a: &Val, b: &Val) {

Callers 1

bench_callsFunction · 0.85

Calls 5

run_awaitFunction · 0.85
use_asyncMethod · 0.80
unwrapMethod · 0.45
call_asyncMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected