Crates.io | wasmprof |
lib.rs | wasmprof |
version | 0.7.0 |
source | src |
created_at | 2023-05-09 15:35:07.472169 |
updated_at | 2024-08-02 12:03:18.455784 |
description | wasmprof allows to profile code running inside of wasmtime |
homepage | https://github.com/Shopify/wasmprof |
repository | |
max_upload_size | |
id | 860640 |
size | 72,917 |
A library that allows to profile code running inside of wasmtime
// 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.