Skip to content

Commit ddbb6be

Browse files
authored
update bencher deps (#872)
1 parent 80ed32d commit ddbb6be

15 files changed

Lines changed: 70 additions & 50 deletions

File tree

Cargo.dev.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ members = [
44
"auction",
55
"authority",
66
"bencher",
7+
"bencher/test",
78
"benchmarking",
89
"currencies",
910
"gradually-update",
@@ -26,6 +27,8 @@ members = [
2627
"payments"
2728
]
2829

30+
exclude = ["bencher/test"]
31+
2932
resolver = "2"
3033

3134
[profile.dev]

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ dev-check: Cargo.toml check
4444

4545
dev-check-tests: Cargo.toml
4646
cargo check --tests --all
47+
cargo check --tests --features=bench --package=orml-weight-meter --package=orml-bencher-test
4748

4849
dev-test: Cargo.toml
49-
cargo test --all --features runtime-benchmarks
50+
cargo test --all --features=runtime-benchmarks
51+
cargo test --features=bench --package=orml-weight-meter --package=orml-bencher-test
5052

5153
# run benchmarks via Acala node
5254
benchmark-all:

bencher/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ edition = "2021"
1010
[dependencies]
1111
paste = "1.0.7"
1212
build-helper = { version = "0.1.1", optional = true }
13-
cargo_metadata = { version = "0.14.1", optional = true }
13+
cargo_metadata = { version = "0.15.2", optional = true }
1414
tempfile = { version = "3.2.0", optional = true }
1515
toml = { version = "0.5.8", optional = true }
1616
walkdir = { version = "2.3.1", optional = true }
1717
ansi_term = { version = "0.12.1", optional = true }
1818
wasm-gc-api = { version = "0.1.11", optional = true }
1919
rand = {version = "0.8.3", optional = true }
20-
linregress = { version = "0.4.4", optional = true }
21-
parking_lot = { version = "0.12.0", optional = true }
20+
linregress = { version = "0.5.0", optional = true }
21+
parking_lot = { version = "0.12.1", optional = true }
2222
thiserror = { version = "1.0", optional = true }
2323
serde = { version = "1.0.136", optional = true, features = ['derive'] }
2424
serde_json = {version = "1.0.68", optional = true }
@@ -35,7 +35,7 @@ sc-executor = { git = "https://github.com/paritytech/substrate", default-feature
3535
sc-executor-common = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.36" }
3636
sc-client-db = { git = "https://github.com/paritytech/substrate", default-features = false, features = ["rocksdb"], optional = true , branch = "polkadot-v0.9.36" }
3737
sp-maybe-compressed-blob = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.36" }
38-
frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.36" }
38+
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.36" }
3939
sp-externalities = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.36" }
4040
sp-storage = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true , branch = "polkadot-v0.9.36" }
4141

@@ -67,7 +67,7 @@ std = [
6767
"sc-executor-common",
6868
"sc-client-db",
6969
"sp-maybe-compressed-blob",
70-
"frame-benchmarking/std",
70+
"frame-support/std",
7171
"sp-externalities/std",
7272
"sp-storage/std",
7373
]

bencher/src/bench_runner.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@ use super::{
22
bench_ext::BenchExt,
33
tracker::{BenchTracker, BenchTrackerExt},
44
};
5-
use frame_benchmarking::frame_support::sp_runtime::traits::Block;
5+
use frame_support::sp_runtime::traits::Block;
66
use sc_executor::{WasmExecutionMethod, WasmExecutor, WasmtimeInstantiationStrategy};
77
use sc_executor_common::runtime_blob::RuntimeBlob;
88
use sp_externalities::Extensions;
99
use sp_state_machine::{Ext, OverlayedChanges, StorageTransactionCache};
1010
use sp_std::sync::Arc;
1111

12-
type ComposeHostFunctions = (
13-
sp_io::SubstrateHostFunctions,
14-
frame_benchmarking::benchmarking::HostFunctions,
15-
super::bench::HostFunctions,
16-
);
12+
type ComposeHostFunctions = (sp_io::SubstrateHostFunctions, super::bench::HostFunctions);
1713

1814
/// Run benches
1915
pub fn run<B: Block>(wasm_code: Vec<u8>) -> std::result::Result<Vec<u8>, sc_executor_common::error::Error> {

bencher/src/bencher.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ impl Bencher {
4040
pub fn before_run(&self) {
4141
#[cfg(not(feature = "std"))]
4242
{
43-
frame_benchmarking::benchmarking::commit_db();
44-
frame_benchmarking::benchmarking::wipe_db();
43+
crate::bench::commit_db();
44+
crate::bench::wipe_db();
4545
}
4646
}
4747

@@ -56,8 +56,8 @@ impl Bencher {
5656
{
5757
#[cfg(not(feature = "std"))]
5858
{
59-
frame_benchmarking::benchmarking::commit_db();
60-
frame_benchmarking::benchmarking::reset_read_write_count();
59+
crate::bench::commit_db();
60+
crate::bench::reset_read_write_count();
6161
crate::bench::start_timer();
6262
}
6363

@@ -68,7 +68,7 @@ impl Bencher {
6868
let elapsed = crate::bench::end_timer().saturating_sub(crate::bench::redundant_time());
6969
self.current.elapses.push(elapsed);
7070

71-
frame_benchmarking::benchmarking::commit_db();
71+
crate::bench::commit_db();
7272

7373
// changed keys
7474
self.current.keys = crate::bench::read_written_keys();

bencher/src/handler.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{
33
BenchResult,
44
};
55
use codec::Decode;
6-
use frame_benchmarking::frame_support::traits::StorageInfo;
6+
use frame_support::traits::StorageInfo;
77
use linregress::{FormulaRegressionBuilder, RegressionDataBuilder};
88
use serde::{Deserialize, Serialize};
99
use sp_core::hexdisplay::HexDisplay;
@@ -66,14 +66,13 @@ pub fn handle(output: Vec<u8>, storage_infos: Vec<StorageInfo>) {
6666

6767
comments.sort();
6868

69+
let intercepted_value = model.parameters()[0] as u64;
70+
6971
println!(
7072
"{} {:<40} {:>20} storage: {:<20}",
7173
green_bold("Bench"),
7274
cyan(&name),
73-
green_bold(&format!(
74-
"{:?}",
75-
Duration::from_nanos(model.parameters.intercept_value as u64)
76-
)),
75+
green_bold(&format!("{:?}", Duration::from_nanos(intercepted_value))),
7776
green_bold(&format!(
7877
"[r: {}, w: {}]",
7978
&total_reads.to_string(),
@@ -83,7 +82,7 @@ pub fn handle(output: Vec<u8>, storage_infos: Vec<StorageInfo>) {
8382

8483
BenchData {
8584
name,
86-
weight: model.parameters.intercept_value as u64 * 1_000,
85+
weight: intercepted_value * 1_000,
8786
reads: total_reads,
8887
writes: total_writes,
8988
comments,

bencher/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![cfg_attr(not(feature = "std"), no_std)]
22

33
#[doc(hidden)]
4-
pub extern crate frame_benchmarking;
4+
pub extern crate frame_support;
55
#[doc(hidden)]
66
pub extern crate paste;
77
#[doc(hidden)]

bencher/src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ macro_rules! run_benches {
125125
) => {
126126
#[cfg(all(feature = "std", feature = "bench"))]
127127
pub fn main() -> std::io::Result<()> {
128-
use $crate::frame_benchmarking::frame_support::traits::StorageInfoTrait;
128+
use $crate::frame_support::traits::StorageInfoTrait;
129129
let wasm = $crate::build_wasm::build()?;
130130
let storage_info = $all_pallets_with_system::storage_info();
131131
match $crate::bench_runner::run::<$block>(wasm) {

bencher/src/utils.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ pub trait Bench {
3636
println!("{}", msg);
3737
}
3838

39+
fn commit_db(&mut self) {
40+
self.commit()
41+
}
42+
43+
fn wipe_db(&mut self) {
44+
self.wipe()
45+
}
46+
47+
fn reset_read_write_count(&mut self) {
48+
self.reset_read_write_count()
49+
}
50+
3951
fn start_timer(&mut self) {
4052
let tracker = &***self
4153
.extension::<BenchTrackerExt>()

bencher/test/Cargo.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,15 @@ std = [
3232
"serde",
3333
"scale-info/std",
3434
"codec/std",
35-
"orml-bencher/std",
3635
"frame-support/std",
3736
"frame-system/std",
3837
"sp-runtime/std",
39-
"sp-std/std",
4038
"sp-core/std",
39+
"sp-std/std",
40+
"orml-bencher/std",
4141
"orml-weight-meter/std",
4242
]
4343
bench = [
4444
"orml-bencher/bench",
4545
"orml-weight-meter/bench",
46-
"frame-support/runtime-benchmarks",
47-
"sp-runtime/runtime-benchmarks",
48-
"frame-system/runtime-benchmarks",
4946
]

0 commit comments

Comments
 (0)