mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 10:31:04 +00:00
[subsystem-benchmarks] Log standart deviation for subsystem-benchmarks (#4285)
Should help us to understand more what's happening between individual runs and possibly adjust the number of runs
This commit is contained in:
@@ -161,6 +161,13 @@ impl ResourceUsage {
|
||||
for (resource_name, values) in by_name {
|
||||
let total = values.iter().map(|v| v.total).sum::<f64>() / values.len() as f64;
|
||||
let per_block = values.iter().map(|v| v.per_block).sum::<f64>() / values.len() as f64;
|
||||
let per_block_sd =
|
||||
standard_deviation(&values.iter().map(|v| v.per_block).collect::<Vec<f64>>());
|
||||
println!(
|
||||
"[{}] standart_deviation {:.2}%",
|
||||
resource_name,
|
||||
per_block_sd / per_block * 100.0
|
||||
);
|
||||
average.push(Self { resource_name, total, per_block });
|
||||
}
|
||||
average
|
||||
@@ -179,3 +186,11 @@ pub struct ChartItem {
|
||||
pub unit: String,
|
||||
pub value: f64,
|
||||
}
|
||||
|
||||
fn standard_deviation(values: &[f64]) -> f64 {
|
||||
let n = values.len() as f64;
|
||||
let mean = values.iter().sum::<f64>() / n;
|
||||
let variance = values.iter().map(|v| (v - mean).powi(2)).sum::<f64>() / (n - 1.0);
|
||||
|
||||
variance.sqrt()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user