For benchmarking I can see a need to use random number generators for maybe verification of a random storage or such. Do we have utilities provided by the frame_benchmarking framework itself or is it possible to bring in std dependencies for benchmarking?

1 Answer 1


Benchmarks compile to WASM and can thereby not access std.

Now in most cases it is enough to use a deterministic pseudorandom source like the output of a cryptographic hash. You can easily do this by defining a seed and recursively calling Blake2 on it to generate as much "random" data as needed.
This has the advantage of being deterministic - benchmarks should always be deterministic for reproducibility.
But in general; std crates and hardware random number generators are not accessible.

(There could be a way to speparate the benchmarking setup from the actual execution, and thereby allow std in the setup phase, but it is just an idea - not anything that will be implemented any time soon.)

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.