In my benchmarks, I've written multiple benchmarks for an extrinsic to cover different scenarios, which gave me WeightIinfo for each of my benchmarks.
Now the question here is how I can pick the worst scenario for my extrinsic dynamically?
Good question!
The #[pallet::weight(…)]
annotation allows you to do some light compile-time computations.
This makes it possible to calculate a maximum like this:
#[pallet::weight(T::WeightInfo::slow().max(T::WeightInfo::slower()))]
One example of this can be found in the bags-list pallet.
It is important to only do very lightweight calculations here, since the terms are evaluated to judge whether or not an extrinsic should be able to execute.
I think the most complicated weight terms are in the utility pallet.