|
1 | 1 | # Timing Loops |
2 | 2 |
|
3 | | -The [`Bencher`](https://bheisler.github.io/criterion.rs/criterion/struct.Bencher.html) structure |
| 3 | +The [`Bencher`](https://criterion-rs.github.io/criterion/struct.Bencher.html.FIXME) structure |
4 | 4 | provides a number of functions which implement different timing loops for measuring the performance |
5 | 5 | of a function. This page discusses how these timing loops work and which one is appropriate for |
6 | 6 | different situations. |
@@ -41,21 +41,21 @@ could run out of memory while collecting the values to drop. |
41 | 41 | timing loops take two closures rather than one. The first closure takes no arguments and returns |
42 | 42 | a value of type `T` - this is used to generate setup data. For example, the setup function might |
43 | 43 | clone a vector of unsorted data for use in benchmarking a sorting function. The second closure |
44 | | -is the function to benchmark, and it takes a `T` (for `iter_batched`) or `&mut T` (for |
| 44 | +is the function to benchmark, and it takes a `T` (for `iter_batched`) or `&mut T` (for |
45 | 45 | `iter_batched_ref`). |
46 | 46 |
|
47 | 47 | These two timing loops generate a batch of inputs and measure the time to execute the benchmark on |
48 | 48 | all values in the batch. As with `iter_with_large_drop` they also collect the values returned from |
49 | 49 | the benchmark into a `Vec` and drop it later without timing the drop. Then another batch of inputs |
50 | 50 | is generated and the process is repeated until enough iterations of the benchmark have been measured. |
51 | | -Keep in mind that this is only necessary if the benchmark modifies the input - if the input is |
| 51 | +Keep in mind that this is only necessary if the benchmark modifies the input - if the input is |
52 | 52 | constant then one input value can be reused and the benchmark should use `iter` instead. |
53 | 53 |
|
54 | 54 | Both timing loops accept a third parameter which controls how large a batch is. If the batch size |
55 | 55 | is too large, we might run out of memory generating the inputs and collecting the outputs. If it's |
56 | 56 | too small, we could introduce more measurement overhead than is necessary. For ease of use, Criterion |
57 | | -provides three pre-defined choices of batch size, defined by the |
58 | | -[`BatchSize`](https://bheisler.github.io/criterion.rs/criterion/enum.BatchSize.html) enum - |
| 57 | +provides three pre-defined choices of batch size, defined by the |
| 58 | +[`BatchSize`](https://criterion-rs.github.io/criterion/enum.BatchSize.html.FIXME) enum - |
59 | 59 | `SmallInput`, `LargeInput` and `PerIteration`. It is also possible (though not recommended) to set |
60 | 60 | the batch size manually. |
61 | 61 |
|
@@ -88,7 +88,7 @@ more control over the batch size which may be necessary in some situations. |
88 | 88 | ## `iter_custom` |
89 | 89 |
|
90 | 90 | This is a special "timing loop" that relies on you to do your own timing. Where the other timing |
91 | | -loops take a lambda to call N times in a loop, this takes a lambda of the form |
| 91 | +loops take a lambda to call N times in a loop, this takes a lambda of the form |
92 | 92 | `FnMut(iters: u64) -> M::Value` - meaning that it accepts the number of iterations and returns |
93 | 93 | the measured value. Typically, this will be a `Duration` for the default `WallTime` measurement, |
94 | 94 | but it may be other types for other measurements (see the |
|
0 commit comments