diff options
Diffstat (limited to 'src/simtest')
| -rw-r--r-- | src/simtest/bench.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/simtest/bench.rs b/src/simtest/bench.rs index ba8995c..82c8985 100644 --- a/src/simtest/bench.rs +++ b/src/simtest/bench.rs @@ -496,10 +496,44 @@ async fn run(seed: u64, scenario: &'static Scenario) -> String { (start, Totals::of(&nodes).await), converged, ); + trees(&mut out, &nodes).await; } out } +/// Every node's own writer's tree (`swarm::tree::own_shape`, `/admin/stats`), as it +/// computes it at the end: the hops its writes take, and the members it leaves out. +async fn trees(out: &mut String, nodes: &[AppState]) { + let mut shapes = Vec::new(); + for node in nodes { + shapes.extend(crate::swarm::tree::own_shape(node).await); + } + if shapes.is_empty() { + return; + } + let count = shapes.len() as f64; + let members: usize = shapes.iter().map(|shape| shape.members).sum(); + let hops: u64 = shapes.iter().map(|shape| shape.hops).sum(); + let deepest = shapes.iter().map(|shape| shape.depth).max().unwrap_or(0); + let depth: f64 = shapes + .iter() + .map(|shape| f64::from(shape.depth)) + .sum::<f64>() + / count; + let off: usize = shapes.iter().map(|shape| shape.off).sum(); + let _ = writeln!( + out, + " own trees ({} nodes): depth {depth:.1} on average, {deepest} at most; {:.2} hops to a member on average; {:.1} members off each", + shapes.len(), + if members > 0 { + hops as f64 / members as f64 + } else { + 0.0 + }, + off as f64 / count, + ); +} + /// The workload's counts (`during`), and the quiet phase's for as long. fn report( out: &mut String, |
