4

How to benchmark the code's WASM execution performance?

I wrote a crate and want to use it in the runtime.

I want to know its WASM execution time in ms. How can I get that?

1 Answer 1

1

FRAME is not a stand-alone WASM benchmarking framework. You can use criterion or similar for that.

The FRAME benchmarking is only concerned about the Weight of calls, not primarily miliseconds.
You could sure put the logic into a minimal pallet and call that. This can work, but is really not the intended use-case of the FRAME benchmarking. If you want to optimize the performance of low-level code it is better to go with other tools.

2
  • Yep, I agree with this. I want to write a "Rust" benchmark without any Substrate deps. Sure, I can use the criterion. But how can I the WASM performance? I don't want the native host benchmarking result. Then I can find some ways to transform that performance result to weight.
    – aurexav
    Commented Mar 14, 2023 at 15:52
  • AFAIK criterion has first class WASM support. I have not used it so far, but it should be possible to compile it to WASM. There is a readme for wasi, maybe that helps. Note that Substrate uses wasmtime. Commented Mar 14, 2023 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.