(c: &mut Criterion)
| 4 | use wasmtime::*; |
| 5 | |
| 6 | fn measure_execution_time(c: &mut Criterion) { |
| 7 | // Baseline performance: a single measurement covers both initializing |
| 8 | // thread local resources and executing the first call. |
| 9 | // |
| 10 | // The other two bench functions should sum to this duration. |
| 11 | c.bench_function("lazy initialization at call", move |b| { |
| 12 | let (engine, module) = test_setup(); |
| 13 | b.iter_custom(move |iters| { |
| 14 | (0..iters) |
| 15 | .map(|_| lazy_thread_instantiate(engine.clone(), module.clone())) |
| 16 | .sum() |
| 17 | }) |
| 18 | }); |
| 19 | |
| 20 | // Using Engine::tls_eager_initialize: measure how long eager |
| 21 | // initialization takes on a new thread. |
| 22 | c.bench_function("eager initialization", move |b| { |
| 23 | let (engine, module) = test_setup(); |
| 24 | b.iter_custom(move |iters| { |
| 25 | (0..iters) |
| 26 | .map(|_| { |
| 27 | let (init, _call) = eager_thread_instantiate(engine.clone(), module.clone()); |
| 28 | init |
| 29 | }) |
| 30 | .sum() |
| 31 | }) |
| 32 | }); |
| 33 | |
| 34 | // Measure how long the first call takes on a thread after it has been |
| 35 | // eagerly initialized. |
| 36 | c.bench_function("call after eager initialization", move |b| { |
| 37 | let (engine, module) = test_setup(); |
| 38 | b.iter_custom(move |iters| { |
| 39 | (0..iters) |
| 40 | .map(|_| { |
| 41 | let (_init, call) = eager_thread_instantiate(engine.clone(), module.clone()); |
| 42 | call |
| 43 | }) |
| 44 | .sum() |
| 45 | }) |
| 46 | }); |
| 47 | } |
| 48 | |
| 49 | /// Creating a store and measuring the time to perform a call is the same behavior |
| 50 | /// in both setups. |
nothing calls this directly
no test coverage detected