Updates Benchmark macro parsing to use Generic Argument (#13919)

* WIP

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Removes POC code

* Adds assertion and UT

* adds runtime error

* removes const_assert

* ".git/.scripts/commands/fmt/fmt.sh"

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: command-bot <>
This commit is contained in:
gupnik
2023-04-14 22:54:26 +05:30
committed by GitHub
parent 8d06402e2e
commit cd1e51a4e7
4 changed files with 41 additions and 40 deletions
@@ -1,16 +0,0 @@
use frame_benchmarking::v2::*;
#[allow(unused_imports)]
use frame_support_test::Config;
#[benchmarks]
mod benches {
use super::*;
#[benchmark]
fn bench(x: Linear<3, 1>) {
#[block]
{}
}
}
fn main() {}
@@ -1,5 +0,0 @@
error: The start of a `ParamRange` must be less than or equal to the end
--> tests/benchmark_ui/bad_param_range.rs:10:21
|
10 | fn bench(x: Linear<3, 1>) {
| ^
@@ -0,0 +1,28 @@
use frame_benchmarking::v2::*;
use frame_support_test::Config;
use frame_support::parameter_types;
#[benchmarks]
mod benches {
use super::*;
const MY_CONST: u32 = 100;
const fn my_fn() -> u32 {
200
}
parameter_types! {
const MyConst: u32 = MY_CONST;
}
#[benchmark(skip_meta, extra)]
fn bench(a: Linear<{MY_CONST * 2}, {my_fn() + MyConst::get()}>) {
let a = 2 + 2;
#[block]
{}
assert_eq!(a, 4);
}
}
fn main() {}