people_westend_runtime/weights/paritydb_weights.rs
1// Copyright (C) Parity Technologies (UK) Ltd.
2// SPDX-License-Identifier: Apache-2.0
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16pub mod constants {
17 use frame_support::{
18 parameter_types,
19 weights::{constants, RuntimeDbWeight},
20 };
21
22 parameter_types! {
23 /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights
24 /// are available for brave runtime engineers who may want to try this out as default.
25 pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight {
26 read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
27 write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
28 };
29 }
30
31 #[cfg(test)]
32 mod test_db_weights {
33 use super::constants::ParityDbWeight as W;
34 use frame_support::weights::constants;
35
36 /// Checks that all weights exist and have sane values.
37 // NOTE: If this test fails but you are sure that the generated values are fine,
38 // you can delete it.
39 #[test]
40 fn sane() {
41 // At least 1 µs.
42 assert!(
43 W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
44 "Read weight should be at least 1 µs."
45 );
46 assert!(
47 W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
48 "Write weight should be at least 1 µs."
49 );
50 // At most 1 ms.
51 assert!(
52 W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
53 "Read weight should be at most 1 ms."
54 );
55 assert!(
56 W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
57 "Write weight should be at most 1 ms."
58 );
59 }
60 }
61}