Skip to content

Commit 46ebb24

Browse files
shawntabriziarkpar
andauthored
Benchmarks Writer CLI (#6567)
* initial mockup * add and wipe * track writes * start to add to pipeline * return all reads/writes * Log reads and writes from bench db * causes panic * Allow multiple commits * commit before ending benchmark * doesn't work??? * fix * Update lib.rs * switch to struct for `BenchmarkResults` * add to output * fix test * line width * @kianenigma review * Add Whitelist to DB Tracking in Benchmarks Pipeline (#6405) * hardcoded whitelist * Add whitelist to pipeline * Remove whitelist pipeline from CLI, add to runtime * clean-up unused db initialized whitelist * Add regression analysis to DB Tracking (#6475) * Add selector * add tests * debug formatter for easy formula * initial idea * use all benchmarks * broken * working without trait * Make work for multiple pallets * Fix merge issues * writer appends to file * implement () for balances weight trait * update name of trait * Weights to WeightInfo * auto trait writer * Heap pages are configurable * clean out runtime changes * more clean up * Fix string generation * Update comments * Update bin/node/runtime/src/lib.rs Co-authored-by: arkpar <arkady.paronyan@gmail.com>
1 parent 06a3ccf commit 46ebb24

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

src/analysis.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ use linregress::{FormulaRegressionBuilder, RegressionDataBuilder, RegressionMode
2222
use crate::BenchmarkResults;
2323

2424
pub struct Analysis {
25-
base: u128,
26-
slopes: Vec<u128>,
27-
names: Vec<String>,
28-
value_dists: Option<Vec<(Vec<u32>, u128, u128)>>,
29-
model: Option<RegressionModel>,
25+
pub base: u128,
26+
pub slopes: Vec<u128>,
27+
pub names: Vec<String>,
28+
pub value_dists: Option<Vec<(Vec<u32>, u128, u128)>>,
29+
pub model: Option<RegressionModel>,
3030
}
3131

3232
pub enum BenchmarkSelector {

src/lib.rs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,31 +1158,46 @@ macro_rules! impl_benchmark_test {
11581158
/// First create an object that holds in the input parameters for the benchmark:
11591159
///
11601160
/// ```ignore
1161-
/// let params = (&pallet, &benchmark, &lowest_range_values, &highest_range_values, &steps, repeat);
1161+
/// let params = (&pallet, &benchmark, &lowest_range_values, &highest_range_values, &steps, repeat, &whitelist);
11621162
/// ```
11631163
///
1164+
/// The `whitelist` is a `Vec<Vec<u8>>` of storage keys that you would like to skip for DB tracking. For example:
1165+
///
1166+
/// ```ignore
1167+
/// let whitelist: Vec<Vec<u8>> = vec![
1168+
/// // Block Number
1169+
/// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec(),
1170+
/// // Total Issuance
1171+
/// hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec(),
1172+
/// // Execution Phase
1173+
/// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec(),
1174+
/// // Event Count
1175+
/// hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec(),
1176+
/// ];
1177+
///
11641178
/// Then define a mutable local variable to hold your `BenchmarkBatch` object:
11651179
///
11661180
/// ```ignore
11671181
/// let mut batches = Vec::<BenchmarkBatch>::new();
11681182
/// ````
11691183
///
1170-
/// Then add the pallets you want to benchmark to this object, including the string
1171-
/// you want to use target a particular pallet:
1184+
/// Then add the pallets you want to benchmark to this object, using their crate name and generated
1185+
/// module struct:
11721186
///
11731187
/// ```ignore
1174-
/// add_benchmark!(params, batches, b"balances", Balances);
1175-
/// add_benchmark!(params, batches, b"identity", Identity);
1176-
/// add_benchmark!(params, batches, b"session", SessionBench::<Runtime>);
1188+
/// add_benchmark!(params, batches, pallet_balances, Balances);
1189+
/// add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>);
1190+
/// add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
11771191
/// ...
11781192
/// ```
11791193
///
11801194
/// At the end of `dispatch_benchmark`, you should return this batches object.
11811195
#[macro_export]
11821196
macro_rules! add_benchmark {
1183-
( $params:ident, $batches:ident, $name:literal, $( $location:tt )* ) => (
1197+
( $params:ident, $batches:ident, $name:ident, $( $location:tt )* ) => (
1198+
let name_string = stringify!($name).as_bytes();
11841199
let (pallet, benchmark, lowest_range_values, highest_range_values, steps, repeat, whitelist) = $params;
1185-
if &pallet[..] == &$name[..] || &pallet[..] == &b"*"[..] {
1200+
if &pallet[..] == &name_string[..] || &pallet[..] == &b"*"[..] {
11861201
if &pallet[..] == &b"*"[..] || &benchmark[..] == &b"*"[..] {
11871202
for benchmark in $( $location )*::benchmarks().into_iter() {
11881203
$batches.push($crate::BenchmarkBatch {
@@ -1194,7 +1209,7 @@ macro_rules! add_benchmark {
11941209
repeat,
11951210
whitelist,
11961211
)?,
1197-
pallet: $name.to_vec(),
1212+
pallet: name_string.to_vec(),
11981213
benchmark: benchmark.to_vec(),
11991214
});
12001215
}
@@ -1208,7 +1223,7 @@ macro_rules! add_benchmark {
12081223
repeat,
12091224
whitelist,
12101225
)?,
1211-
pallet: $name.to_vec(),
1226+
pallet: name_string.to_vec(),
12121227
benchmark: benchmark.clone(),
12131228
});
12141229
}

0 commit comments

Comments
 (0)