Skip to content

Commit

Permalink
Merge pull request #2274 from subspace/benchmark-example-update
Browse files Browse the repository at this point in the history
Update benchmark example in subspace-networking crate.
  • Loading branch information
shamil-gadelshin authored Nov 27, 2023
2 parents 2d374fe + 320b669 commit f6599f3
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion crates/subspace-networking/examples/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ enum Command {
retries: u16,
#[arg(long, default_value_t = 1)]
parallelism_level: u16,
#[arg(long, default_value_t = 1)]
repeat: u16,
},
}

Expand Down Expand Up @@ -92,8 +94,17 @@ async fn main() {
start_with,
retries,
parallelism_level,
repeat,
} => {
parallel_benchmark(node, max_pieces, start_with, retries, parallelism_level).await;
parallel_benchmark(
node,
max_pieces,
start_with,
retries,
parallelism_level,
repeat,
)
.await;
}
}

Expand Down Expand Up @@ -181,6 +192,7 @@ async fn parallel_benchmark(
start_with: usize,
retries: u16,
parallelism_level: u16,
repeat: u16,
) {
let start = Instant::now();
let mut stats = PieceRequestStats::default();
Expand All @@ -195,6 +207,8 @@ async fn parallel_benchmark(
let mut total_duration = Duration::default();
let mut pure_total_duration = Duration::default();
let mut pending_pieces = (start_with..(start_with + max_pieces))
.cycle()
.take(max_pieces * repeat as usize)
.map(|i| {
let piece_index = PieceIndex::from(i as u64);
async move {
Expand Down

0 comments on commit f6599f3

Please sign in to comment.