(c: &mut Criterion)
| 54 | } |
| 55 | |
| 56 | fn 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 | |
| 98 | criterion_group!(benches, criterion_benchmark); |
| 99 | criterion_main!(benches); |
nothing calls this directly
no test coverage detected