From 45b0d10d38e3c56ec46f2a36efff471941702702 Mon Sep 17 00:00:00 2001 From: Shun Kashiwa Date: Mon, 6 Nov 2023 19:14:56 -0800 Subject: [PATCH] add microbenchmark code --- chorus_lib/benches/comm_benchmark.rs | 12 ++++-------- chorus_lib/benches/locally_benchmark.rs | 8 +------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/chorus_lib/benches/comm_benchmark.rs b/chorus_lib/benches/comm_benchmark.rs index 74b8045..d70b7b9 100644 --- a/chorus_lib/benches/comm_benchmark.rs +++ b/chorus_lib/benches/comm_benchmark.rs @@ -2,10 +2,7 @@ use chorus_lib::core::{ ChoreoOp, Choreography, ChoreographyLocation, LocationSet, Projector, Transport, }; use chorus_lib::transport::local::{LocalTransport, LocalTransportChannelBuilder}; -use criterion::{ - black_box, criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion, - PlotConfiguration, -}; +use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion}; use std::thread::spawn; #[derive(ChoreographyLocation)] @@ -96,14 +93,13 @@ fn comm_handwritten(n: u64) { fn bench_comm(c: &mut Criterion) { let mut group = c.benchmark_group("Comm"); - let plot_config = PlotConfiguration::default().summary_scale(AxisScale::Logarithmic); - group.plot_config(plot_config); - for i in [1, 10, 100, 1000, 10000].iter() { + let range = [2000, 4000, 6000, 8000, 10000]; + for i in range.iter() { group.bench_with_input(BenchmarkId::new("Handwritten", i), i, |b, i| { b.iter(|| comm_handwritten(black_box(*i))) }); } - for i in [1, 10, 100, 1000, 10000].iter() { + for i in range.iter() { group.bench_with_input(BenchmarkId::new("Choreographic", i), i, |b, i| { b.iter(|| comm_choreography(black_box(*i))) }); diff --git a/chorus_lib/benches/locally_benchmark.rs b/chorus_lib/benches/locally_benchmark.rs index a00592b..b686352 100644 --- a/chorus_lib/benches/locally_benchmark.rs +++ b/chorus_lib/benches/locally_benchmark.rs @@ -1,8 +1,5 @@ use chorus_lib::core::{ChoreoOp, Choreography, ChoreographyLocation, Located, LocationSet}; -use criterion::{ - black_box, criterion_group, criterion_main, AxisScale, BenchmarkId, Criterion, - PlotConfiguration, -}; +use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion}; #[derive(ChoreographyLocation)] struct Alice; @@ -43,9 +40,6 @@ fn add_to_n_locally_handwritten(n: f64) { fn bench_add_to_n_locally(c: &mut Criterion) { let mut group = c.benchmark_group("Locally"); - let plot_config = PlotConfiguration::default().summary_scale(AxisScale::Logarithmic); - // group.plot_config(plot_config); - // let range = [1, 10, 100, 1000, 10000]; let range = [2000, 4000, 6000, 8000, 10000]; for i in range.iter() { group.bench_with_input(BenchmarkId::new("Handwritten", i), i, |b, i| {