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