Weights & Benchmarking
Weight: Unit of computation in Substrate
Bechmarking: Calculating the weights required for one pallet dispatchable function to be executed. Substrate benchmarking framework will re-run the logic calls to the dispatchable function defined in
benchmarking.rs
multiple times.Dispatchable function weights will be specified in
pallet::weights
The Substrate runtime is composed of distinct pallets, each of which expose various dispatchable functions. The weight of each of these functions are completely independent of one another, and can vary based on the logical path executed based on the inputs and existing state.
To benchmark these runtime functions, we execute them within the actual Wasm runtime, in worst case scenarios. With runtime extrinsics where the input or existing state may effect the complexity of the execution, we test the extrinsic by varying those components and using regression analysis to extract results.
The runtime benchmarks are broken into two pieces:
Timing Dispatch Function Logic
Tallying Database Reads and Writes

Write & run a benchmarking
./target/release/substrate benchmark --chain dev --pallet "*" --extrinsic "*" --steps 0
Resources
Benchmarking your Substrate pallets: https://www.youtube.com/watch?v=Qa6sTyUqgek
How to retrieve the computational time for resources in Substrate: https://github.com/paritytech/substrate/discussions/13098
Last updated