6个版本 (破坏性更新)
新增 0.7.0 | 2024年8月2日 |
---|---|
0.5.0 | 2024年4月9日 |
0.4.0 | 2024年4月2日 |
0.3.0 | 2023年11月16日 |
0.1.0 | 2023年5月9日 |
#341 在 性能分析
每月下载 217 次
22KB
406 行
wasmprof
一个库,允许分析运行在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()
})
在示例文件夹中可以找到一个完整的示例: 完整示例。
依赖项
~14–22MB
~327K SLoC