mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 01:41:03 +00:00
[subsystem-benchmarks] Fix availability-write regression tests (#3698)
Adds availability-write regression tests. The results for the `availability-distribution` subsystem are volatile, so I had to reduce the precision of the test.
This commit is contained in:
+31
-22
@@ -14,9 +14,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! availability-write regression tests
|
||||
//! availability-read regression tests
|
||||
//!
|
||||
//! Availability write benchmark based on Kusama parameters and scale.
|
||||
//! Availability read benchmark based on Kusama parameters and scale.
|
||||
//!
|
||||
//! Subsystems involved:
|
||||
//! - availability-recovery
|
||||
@@ -27,8 +27,11 @@ use polkadot_subsystem_bench::{
|
||||
TestDataAvailability, TestState,
|
||||
},
|
||||
configuration::TestConfiguration,
|
||||
utils::{warm_up_and_benchmark, WarmUpOptions},
|
||||
usage::BenchmarkUsage,
|
||||
};
|
||||
use std::io::Write;
|
||||
|
||||
const BENCH_COUNT: usize = 50;
|
||||
|
||||
fn main() -> Result<(), String> {
|
||||
let mut messages = vec![];
|
||||
@@ -38,27 +41,33 @@ fn main() -> Result<(), String> {
|
||||
config.num_blocks = 3;
|
||||
config.generate_pov_sizes();
|
||||
|
||||
let usage = warm_up_and_benchmark(WarmUpOptions::new(&["availability-recovery"]), || {
|
||||
let mut state = TestState::new(&config);
|
||||
let (mut env, _protocol_config) = prepare_test(
|
||||
config.clone(),
|
||||
&mut state,
|
||||
TestDataAvailability::Read(options.clone()),
|
||||
false,
|
||||
);
|
||||
env.runtime().block_on(benchmark_availability_read(
|
||||
"data_availability_read",
|
||||
&mut env,
|
||||
state,
|
||||
))
|
||||
})?;
|
||||
println!("{}", usage);
|
||||
let state = TestState::new(&config);
|
||||
|
||||
messages.extend(usage.check_network_usage(&[
|
||||
("Received from peers", 307200.000, 0.05),
|
||||
("Sent to peers", 1.667, 0.05),
|
||||
println!("Benchmarking...");
|
||||
let usages: Vec<BenchmarkUsage> = (0..BENCH_COUNT)
|
||||
.map(|n| {
|
||||
print!("\r[{}{}]", "#".repeat(n), "_".repeat(BENCH_COUNT - n));
|
||||
std::io::stdout().flush().unwrap();
|
||||
let (mut env, _cfgs) =
|
||||
prepare_test(&state, TestDataAvailability::Read(options.clone()), false);
|
||||
env.runtime().block_on(benchmark_availability_read(
|
||||
"data_availability_read",
|
||||
&mut env,
|
||||
&state,
|
||||
))
|
||||
})
|
||||
.collect();
|
||||
println!("\rDone!{}", " ".repeat(BENCH_COUNT));
|
||||
let average_usage = BenchmarkUsage::average(&usages);
|
||||
println!("{}", average_usage);
|
||||
|
||||
// We expect no variance for received and sent
|
||||
// but use 0.001 because we operate with floats
|
||||
messages.extend(average_usage.check_network_usage(&[
|
||||
("Received from peers", 307200.000, 0.001),
|
||||
("Sent to peers", 1.667, 0.001),
|
||||
]));
|
||||
messages.extend(usage.check_cpu_usage(&[("availability-recovery", 11.500, 0.05)]));
|
||||
messages.extend(average_usage.check_cpu_usage(&[("availability-recovery", 11.500, 0.05)]));
|
||||
|
||||
if messages.is_empty() {
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user