From 7d3fae88e37aa81a069ebf1b9898b90675b669d2 Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Tue, 31 Oct 2023 12:39:42 +0100 Subject: [PATCH] add pallet distance benchmarks --- Cargo.lock | 1 + pallets/distance/Cargo.toml | 8 ++++++++ pallets/distance/src/lib.rs | 5 ++++- pallets/distance/src/weights.rs | 26 ++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 47aee8f69..6e2559994 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5844,6 +5844,7 @@ dependencies = [ name = "pallet-distance" version = "1.0.0" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "pallet-authority-members", diff --git a/pallets/distance/Cargo.toml b/pallets/distance/Cargo.toml index 1a08c2f2f..b1910ffba 100644 --- a/pallets/distance/Cargo.toml +++ b/pallets/distance/Cargo.toml @@ -11,9 +11,11 @@ version = '1.0.0' [features] default = ['std'] +runtime-benchmarks = ['frame-benchmarking/runtime-benchmarks'] std = [ 'codec/std', 'frame-support/std', + 'frame-benchmarking/std', 'pallet-authority-members/std', 'pallet-authorship/std', 'pallet-identity/std', @@ -37,6 +39,12 @@ scale-info = { version = "2.1.1", default-features = false, features = [ "derive", ] } +[dependencies.frame-benchmarking] +default-features = false +git = 'https://github.com/duniter/substrate' +optional = true +branch = 'duniter-substrate-v0.9.42' + [dependencies.codec] default-features = false features = ['derive'] diff --git a/pallets/distance/src/lib.rs b/pallets/distance/src/lib.rs index 92ed6acc0..2fc58a372 100644 --- a/pallets/distance/src/lib.rs +++ b/pallets/distance/src/lib.rs @@ -21,10 +21,13 @@ mod traits; mod types; mod weights; +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmarking; + pub use pallet::*; pub use traits::*; pub use types::*; -// pub use weights::WeightInfo; +pub use weights::WeightInfo; use frame_support::traits::StorageVersion; use pallet_authority_members::SessionIndex; diff --git a/pallets/distance/src/weights.rs b/pallets/distance/src/weights.rs index 8b1378917..9177a415a 100644 --- a/pallets/distance/src/weights.rs +++ b/pallets/distance/src/weights.rs @@ -1 +1,27 @@ +// Copyright 2021-2023 Axiom-Team +// +// This file is part of Duniter-v2S. +// +// Duniter-v2S is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// Duniter-v2S is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. +#![allow(clippy::unnecessary_cast)] + +use frame_support::weights::Weight; + +/// Weight functions needed for pallet_universal_dividend. +pub trait WeightInfo { + fn request_distance_evaluation() -> Weight; + fn update_evaluation() -> Weight; + fn force_update_evaluation() -> Weight; + fn force_set_distance_status() -> Weight; +} -- GitLab