#wasmtime #profiler

wasmprof

wasmprof allows to profile code running inside of wasmtime

6 releases (breaking)

0.7.0 Aug 2, 2024
0.5.0 Apr 9, 2024
0.4.0 Apr 2, 2024
0.3.0 Nov 16, 2023
0.1.0 May 9, 2023

#312 in WebAssembly

Download history 2/week @ 2024-07-20 156/week @ 2024-07-27 76/week @ 2024-08-03 47/week @ 2024-08-10 68/week @ 2024-08-17 52/week @ 2024-08-24 52/week @ 2024-08-31 112/week @ 2024-09-07 43/week @ 2024-09-14 27/week @ 2024-09-21 38/week @ 2024-09-28 51/week @ 2024-10-05 44/week @ 2024-10-12 28/week @ 2024-10-19 70/week @ 2024-10-26 25/week @ 2024-11-02

169 downloads per month

MIT license

22KB
406 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
~351K SLoC