Skip to content

Commit

Permalink
Add bench for bar charts
Browse files Browse the repository at this point in the history
  • Loading branch information
niladic committed Jul 3, 2021
1 parent fd8e344 commit ecf9074
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions egui_demo_lib/benches/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ pub fn criterion_benchmark(c: &mut Criterion) {
plot
}

fn bars_plot(num_of_items: u32, num_of_bars: u32) -> egui::plot::Plot {
let mut plot = egui::plot::Plot::new("Benchmark");
for item_index in 0..num_of_items {
plot = plot.barchart(egui::plot::BarChart::new(
(0..num_of_bars)
.map(|i| egui::plot::Bar::new(i as f64, 1.0).base_offset(item_index as f64))
.collect(),
));
}
plot
}

let mut ctx = egui::CtxRef::default();
let mut group = c.benchmark_group("plots");
group
Expand Down Expand Up @@ -178,6 +190,12 @@ pub fn criterion_benchmark(c: &mut Criterion) {
item_size,
lines_plot,
);
run_plot_bench(
&format!("plot_{}x{}_bars", num_of_items, item_size),
num_of_items,
item_size,
bars_plot,
);
}
group.finish();
}
Expand Down

0 comments on commit ecf9074

Please sign in to comment.