MCPcopy Create free account
hub / github.com/explodingcamera/tinywasm / criterion_benchmark

Function criterion_benchmark

crates/tinywasm/benches/tinywasm_modes.rs:56–96  ·  view source on GitHub ↗
(c: &mut Criterion)

Source from the content-addressed store, hash-verified

54}
55
56fn criterion_benchmark(c: &mut Criterion) {
57 let module = tinywasm_parse().expect("tinywasm_parse");
58 let mut group = c.benchmark_group("tinywasm_modes");
59 group.measurement_time(BENCH_MEASUREMENT_TIME);
60
61 let per_instruction_engine = Engine::new(Config::new().with_fuel_policy(FuelPolicy::PerInstruction));
62 group.bench_function("resume_fuel_per_instruction", |b| {
63 b.iter_batched_ref(
64 || setup_typed_func(&module, Some(per_instruction_engine.clone())).expect("setup fuel per-instruction"),
65 |(store, func)| run_resume_with_fuel(store, func).expect("run fuel per-instruction"),
66 BatchSize::LargeInput,
67 )
68 });
69
70 let weighted_engine = Engine::new(Config::new().with_fuel_policy(FuelPolicy::Weighted));
71 group.bench_function("resume_fuel_weighted", |b| {
72 b.iter_batched_ref(
73 || setup_typed_func(&module, Some(weighted_engine.clone())).expect("setup fuel weighted"),
74 |(store, func)| run_resume_with_fuel(store, func).expect("run fuel weighted"),
75 BatchSize::LargeInput,
76 )
77 });
78
79 group.bench_function("resume_time_budget", |b| {
80 b.iter_batched_ref(
81 || setup_typed_func(&module, None).expect("setup time budget"),
82 |(store, func)| run_resume_with_time_budget(store, func).expect("run time budget"),
83 BatchSize::LargeInput,
84 )
85 });
86
87 group.bench_function("call", |b| {
88 b.iter_batched_ref(
89 || setup_typed_func(&module, None).expect("setup call"),
90 |(store, func)| run_call(store, func).expect("run call"),
91 BatchSize::LargeInput,
92 )
93 });
94
95 group.finish();
96}
97
98criterion_group!(benches, criterion_benchmark);
99criterion_main!(benches);

Callers

nothing calls this directly

Calls 7

setup_typed_funcFunction · 0.85
run_resume_with_fuelFunction · 0.85
run_callFunction · 0.85
with_fuel_policyMethod · 0.80
finishMethod · 0.80
tinywasm_parseFunction · 0.70

Tested by

no test coverage detected