2

I'm trying to use the "let i in x..y" notation while benchmarking, and ran into a problem:

the line let i in 10_000_000_000 .. 100_000_000_000 throw an error, as i is a u32, and my numbers doesn't fit. How can i set i as a u128 ? I tried let i: u128 in..., let i as u128 in... every notation that came to my mind, and didn't manage to find a solution

1 Answer 1

3

Benchmark complexity parameters are always u32. Making them more than u32 wouldn't make sense since they're designed to be iterated over to collect timing data for a linear regression algorithm, and you're never going to want to do more than 4 billion iterations of a timing algorithm.

But you can easily take a u32 and turn it into a u128 with a multiplier:

let x in 10_000 .. 100_000;
let i = x as u128 * 1_000_000u128;
1
  • Damn good idea ! I'll explain why i wanted a u128: I'm trying to benchmark a mint pallet, but the existential deposit was something like 10_000_000_000, so i needed to iterate from this to something like 100B. I see now why its not a good idea, thanks for the answer !
    – Nathan
    May 5, 2022 at 9:37

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.