/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use criterion::{criterion_group, measurement::Measurement, BatchSize, BenchmarkGroup, Criterion}; use std::sync::Once; use suggest::benchmarks::{cleanup, geoname, ingest, query, BenchmarkWithInput};
pubfn geoname(c: &mut Criterion) {
setup_viaduct(); let group = c.benchmark_group("geoname");
run_benchmarks(group, geoname::all_benchmarks())
}
pubfn ingest(c: &mut Criterion) {
setup_viaduct(); letmut group = c.benchmark_group("ingest"); // 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);
run_benchmarks(group, ingest::all_benchmarks())
}
pubfn query(c: &mut Criterion) {
setup_viaduct(); let group = c.benchmark_group("query");
run_benchmarks(group, query::all_benchmarks())
}
fn run_benchmarks<B: BenchmarkWithInput, M: Measurement>( mut group: BenchmarkGroup<M>,
benchmarks: Vec<(&'static str, B)>,
) { for (name, benchmark) in benchmarks { let g_input = benchmark.global_input();
group.bench_function(name.to_string(), |b| {
b.iter_batched(
|| benchmark.iteration_input(),
|i_input| benchmark.benchmarked_code(&g_input, i_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,
);
});
}
group.finish();
}
fn setup_viaduct() { static INIT: Once = Once::new();
INIT.call_once(viaduct_reqwest::use_reqwest_backend);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.