#wasmtime #profiler

wasmprof

wasmprof allows to profile code running inside of wasmtime

8 releases (breaking)

0.9.0 Jan 16, 2025
0.8.0 Dec 16, 2024
0.7.0 Aug 2, 2024
0.5.0 Apr 9, 2024
0.1.0 May 9, 2023

#346 in WebAssembly

Download history 36/week @ 2024-11-13 14/week @ 2024-11-20 16/week @ 2024-11-27 74/week @ 2024-12-04 175/week @ 2024-12-11 76/week @ 2024-12-18 7/week @ 2024-12-25 47/week @ 2025-01-08 196/week @ 2025-01-15 24/week @ 2025-01-22 27/week @ 2025-01-29 14/week @ 2025-02-05 27/week @ 2025-02-12 23/week @ 2025-02-19 29/week @ 2025-02-26

94 downloads per month

MIT license

23KB
412 lines

wasmprof

A library that allows to profile code running inside of wasmtime

How to use it

// First you want to create a `ProfilerBuilder` like so:
// Here we are assuming that you have a `Wasmtime::Store` to pass to the builder.
let builder = ProfilerBuilder::new(&mut store);

// Then you can set the frequency at which it's going to sample and the kind of weight to use:
// Here we are setting the frequency to 1000 (sampling 1000 in a second) and we chose `Fuel` as the weight
let builder = builder
    .frequency(1000)
    .weight_unit(wasmprof::WeightUnit::Fuel);

// finally we can start profiling
builder.profile(|store| {
    // here you would invoke some wasm function though wasmtime, something like this:
    let func = instance
                .get_typed_func::<i32, i32>(store.as_context_mut(), "fib")
                .unwrap();
    func.call(store.as_context_mut(), 40).unwrap()
})

A complete example can be found in the examples folder.

Dependencies

~15–23MB
~347K SLoC