mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 10:01:17 +00:00
Benchmarking: Add pov_mode to V2 syntax (#3616)
Changes: - Port the `pov_mode` attribute from the V1 syntax to V2 - Update `pallet-whitelist` and `frame-benchmarking-pallet-pov` Follow up: also allow this attribute on top-level benchmark modules. --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: command-bot <>
This commit is contained in:
committed by
GitHub
parent
430ad2f561
commit
abd3f0c49a
@@ -0,0 +1,31 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use frame_benchmarking::v2::*;
|
||||
|
||||
#[benchmarks]
|
||||
mod benches {
|
||||
use super::*;
|
||||
|
||||
#[benchmark(pov_mode = Wrong)]
|
||||
fn bench() {
|
||||
#[block]
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: expected one of: `MaxEncodedLen`, `Measured`, `Ignored`
|
||||
--> tests/benchmark_ui/bad_attr_pov_mode_1.rs:24:25
|
||||
|
|
||||
24 | #[benchmark(pov_mode = Wrong)]
|
||||
| ^^^^^
|
||||
@@ -0,0 +1,33 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use frame_benchmarking::v2::*;
|
||||
|
||||
#[benchmarks]
|
||||
mod benches {
|
||||
use super::*;
|
||||
|
||||
#[benchmark(pov_mode = Measured {
|
||||
Key: Wrong
|
||||
})]
|
||||
fn bench() {
|
||||
#[block]
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: expected one of: `MaxEncodedLen`, `Measured`, `Ignored`
|
||||
--> tests/benchmark_ui/bad_attr_pov_mode_2.rs:25:8
|
||||
|
|
||||
25 | Key: Wrong
|
||||
| ^^^^^
|
||||
@@ -0,0 +1,31 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use frame_benchmarking::v2::*;
|
||||
|
||||
#[benchmarks]
|
||||
mod benches {
|
||||
use super::*;
|
||||
|
||||
#[benchmark(pov_mode)]
|
||||
fn bench() {
|
||||
#[block]
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: expected `=`
|
||||
--> tests/benchmark_ui/bad_attr_pov_mode_3.rs:24:22
|
||||
|
|
||||
24 | #[benchmark(pov_mode)]
|
||||
| ^
|
||||
@@ -0,0 +1,31 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use frame_benchmarking::v2::*;
|
||||
|
||||
#[benchmarks]
|
||||
mod benches {
|
||||
use super::*;
|
||||
|
||||
#[benchmark(pov_mode =)]
|
||||
fn bench() {
|
||||
#[block]
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
error: unexpected end of input, expected one of: `MaxEncodedLen`, `Measured`, `Ignored`
|
||||
--> tests/benchmark_ui/bad_attr_pov_mode_4.rs:24:24
|
||||
|
|
||||
24 | #[benchmark(pov_mode =)]
|
||||
| ^
|
||||
@@ -0,0 +1,32 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use frame_benchmarking::v2::*;
|
||||
use frame_support_test::Config;
|
||||
|
||||
#[benchmarks]
|
||||
mod benches {
|
||||
use super::*;
|
||||
|
||||
#[benchmark(pov_mode = Measured, pov_mode = MaxEncodedLen)]
|
||||
fn bench() {
|
||||
#[block]
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,14 @@
|
||||
error: unexpected end of input, `pov_mode` can only be specified once
|
||||
--> tests/benchmark_ui/dup_attr_pov_mode.rs:25:59
|
||||
|
|
||||
25 | #[benchmark(pov_mode = Measured, pov_mode = MaxEncodedLen)]
|
||||
| ^
|
||||
|
||||
error: unused import: `frame_support_test::Config`
|
||||
--> tests/benchmark_ui/dup_attr_pov_mode.rs:19:5
|
||||
|
|
||||
19 | use frame_support_test::Config;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D unused-imports` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(unused_imports)]`
|
||||
@@ -0,0 +1,74 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use frame_benchmarking::v2::*;
|
||||
use frame_support_test::Config;
|
||||
|
||||
#[benchmarks]
|
||||
mod benches {
|
||||
use super::*;
|
||||
|
||||
#[benchmark(skip_meta, extra, pov_mode = Measured)]
|
||||
fn bench1() {
|
||||
#[block]
|
||||
{}
|
||||
}
|
||||
|
||||
#[benchmark(pov_mode = Measured, extra, skip_meta)]
|
||||
fn bench2() {
|
||||
#[block]
|
||||
{}
|
||||
}
|
||||
|
||||
#[benchmark(extra, pov_mode = Measured {
|
||||
Pallet: Measured,
|
||||
Pallet::Storage: MaxEncodedLen,
|
||||
}, skip_meta)]
|
||||
fn bench3() {
|
||||
#[block]
|
||||
{}
|
||||
}
|
||||
|
||||
#[benchmark(skip_meta, extra, pov_mode = Measured {
|
||||
Pallet::Storage: MaxEncodedLen,
|
||||
Pallet::StorageSubKey: Measured,
|
||||
})]
|
||||
fn bench4() {
|
||||
#[block]
|
||||
{}
|
||||
}
|
||||
|
||||
#[benchmark(pov_mode = MaxEncodedLen {
|
||||
Pallet::Storage: Measured,
|
||||
Pallet::StorageSubKey: Measured
|
||||
}, extra, skip_meta)]
|
||||
fn bench5() {
|
||||
#[block]
|
||||
{}
|
||||
}
|
||||
|
||||
#[benchmark(pov_mode = MaxEncodedLen {
|
||||
Pallet::Storage: Measured,
|
||||
Pallet::Storage::Nested: Ignored
|
||||
}, extra, skip_meta)]
|
||||
fn bench6() {
|
||||
#[block]
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -22,7 +22,7 @@ use frame_support_test::Config;
|
||||
mod benches {
|
||||
use super::*;
|
||||
|
||||
#[benchmark(skip_meta, extra)]
|
||||
#[benchmark(skip_meta, pov_mode = Measured, extra)]
|
||||
fn bench() {
|
||||
let a = 2 + 2;
|
||||
#[block]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
error: expected `extra` or `skip_meta`
|
||||
error: expected one of: `extra`, `skip_meta`, `pov_mode`
|
||||
--> tests/benchmark_ui/unrecognized_option.rs:26:32
|
||||
|
|
||||
26 | #[benchmark(skip_meta, extra, bad)]
|
||||
|
||||
Reference in New Issue
Block a user