Bug 1870642 - Fix Collection deleted snackbar that overlaps the toolbar r=android...
[gecko.git] / third_party / rust / suggest / src / benchmarks / mod.rs
blobeb3b2e8abe59fd1000ca2be52b38550ba90477e2
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 //! Benchmarking support
6 //!
7 //! Benchmarks are split up into two parts: the functions to be benchmarked live here, which the benchmarking code itself lives in `benches/bench.rs`.
8 //! It's easier to write benchmarking code inside the main crate, where we have access to private items.
9 //! However, it's easier to integrate with Cargo and criterion if benchmarks live in a separate crate.
10 //!
11 //! All benchmarks are defined as structs that implement either the [Benchmark] or [BenchmarkWithInput]
13 pub mod client;
14 pub mod ingest;
16 /// Trait for simple benchmarks
17 ///
18 /// This supports simple benchmarks that don't require any input.  Note: global setup can be done
19 /// in the `new()` method for the struct.
20 pub trait Benchmark {
21     /// Perform the operations that we're benchmarking.
22     fn benchmarked_code(&self);
25 /// Trait for benchmarks that require input
26 ///
27 /// This will run using Criterion's `iter_batched` function.  Criterion will create a batch of
28 /// inputs, then pass each one to benchmark.
29 ///
30 /// This supports simple benchmarks that don't require any input.  Note: global setup can be done
31 /// in the `new()` method for the struct.
32 pub trait BenchmarkWithInput {
33     type Input;
35     /// Generate the input (this is not included in the benchmark time)
36     fn generate_input(&self) -> Self::Input;
38     /// Perform the operations that we're benchmarking.
39     fn benchmarked_code(&self, input: Self::Input);