From 9835e2ae736235810b4ea1c162ca5e65c547e770 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 18 May 2024 04:49:50 +0200 Subject: Merging upstream version 1.71.1+dfsg1. Signed-off-by: Daniel Baumann --- vendor/plotters/benches/benches/data.rs | 37 +++++++++++++++++++++++++++++++++ vendor/plotters/benches/benches/mod.rs | 1 + vendor/plotters/benches/main.rs | 7 +++++++ 3 files changed, 45 insertions(+) create mode 100644 vendor/plotters/benches/benches/data.rs create mode 100644 vendor/plotters/benches/benches/mod.rs create mode 100644 vendor/plotters/benches/main.rs (limited to 'vendor/plotters/benches') diff --git a/vendor/plotters/benches/benches/data.rs b/vendor/plotters/benches/benches/data.rs new file mode 100644 index 000000000..22dc9f4d4 --- /dev/null +++ b/vendor/plotters/benches/benches/data.rs @@ -0,0 +1,37 @@ +use criterion::{criterion_group, Criterion}; +use plotters::data::Quartiles; + +struct Lcg { + state: u32, +} + +impl Lcg { + fn new() -> Lcg { + Lcg { state: 0 } + } +} + +impl Iterator for Lcg { + type Item = u32; + + fn next(&mut self) -> Option { + self.state = self.state.wrapping_mul(1_103_515_245).wrapping_add(12_345); + self.state %= 1 << 31; + Some(self.state) + } +} + +fn quartiles_calc(c: &mut Criterion) { + let src: Vec = Lcg::new().take(100000).collect(); + c.bench_function("data::quartiles_calc", |b| { + b.iter(|| { + Quartiles::new(&src); + }) + }); +} + +criterion_group! { + name = quartiles_group; + config = Criterion::default().sample_size(10); + targets = quartiles_calc +} diff --git a/vendor/plotters/benches/benches/mod.rs b/vendor/plotters/benches/benches/mod.rs new file mode 100644 index 000000000..7a345e4c6 --- /dev/null +++ b/vendor/plotters/benches/benches/mod.rs @@ -0,0 +1 @@ +pub mod data; diff --git a/vendor/plotters/benches/main.rs b/vendor/plotters/benches/main.rs new file mode 100644 index 000000000..f1975f5f0 --- /dev/null +++ b/vendor/plotters/benches/main.rs @@ -0,0 +1,7 @@ +use criterion::criterion_main; + +mod benches; + +criterion_main! { + benches::data::quartiles_group +} -- cgit v1.2.3