summaryrefslogtreecommitdiffstats
path: root/third_party/rust/suggest/benches
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /third_party/rust/suggest/benches
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--third_party/rust/suggest/benches/benchmark_all.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/third_party/rust/suggest/benches/benchmark_all.rs b/third_party/rust/suggest/benches/benchmark_all.rs
new file mode 100644
index 0000000000..2e328e5804
--- /dev/null
+++ b/third_party/rust/suggest/benches/benchmark_all.rs
@@ -0,0 +1,25 @@
+use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
+use suggest::benchmarks::{ingest, BenchmarkWithInput};
+
+pub fn ingest_single_provider(c: &mut Criterion) {
+ let mut group = c.benchmark_group("ingest");
+ viaduct_reqwest::use_reqwest_backend();
+ // This needs to be 10 for now, or else the `ingest-amp-wikipedia` benchmark would take around
+ // 100s to run which feels like too long. `ingest-amp-mobile` also would take a around 50s.
+ group.sample_size(10);
+ for (name, benchmark) in ingest::all_benchmarks() {
+ group.bench_function(format!("ingest-{name}"), |b| {
+ b.iter_batched(
+ || benchmark.generate_input(),
+ |input| benchmark.benchmarked_code(input),
+ // See https://docs.rs/criterion/latest/criterion/enum.BatchSize.html#variants for
+ // a discussion of this. PerIteration is chosen for these benchmarks because the
+ // input holds a database file handle
+ BatchSize::PerIteration,
+ );
+ });
+ }
+}
+
+criterion_group!(benches, ingest_single_provider);
+criterion_main!(benches);