1# Changelog
2
3All notable changes to this project will be documented in this file.
4
5The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
8## [Unreleased]
9
10## [0.4.0] - 2022-09-10
11
12### Removed
13
14- The `Criterion::can_plot` function has been removed.
15- The `Criterion::bench_function_over_inputs` function has been removed.
16- The `Criterion::bench_functions` function has been removed.
17- The `Criterion::bench` function has been removed.
18
19### Changed
20
21- HTML report hidden behind non-default feature flag: 'html_reports'
22- Standalone support (ie without cargo-criterion) feature flag: 'cargo_bench_support'
23- MSRV bumped to 1.57
24- `rayon` and `plotters` are optional (and default) dependencies.
25- Status messages ('warming up', 'analyzing', etc) are printed to stderr, benchmark results are printed to stdout.
26- Accept subsecond durations for `--warm-up-time`, `--measurement-time` and `--profile-time`.
27- Replaced serde_cbor with ciborium because the former is no longer maintained.
28- Upgrade clap to v3 and regex to v1.5.
29
30### Added
31
32- A `--discard-baseline` flag for discarding rather than saving benchmark results.
33- Formal support for benchmarking code compiled to web-assembly.
34- A `--quiet` flag for printing just a single line per benchmark.
35- A `Throughput::BytesDecimal` option for measuring throughput in bytes but printing them using
36  decimal units like kilobytes instead of binary units like kibibytes.
37
38### Fixed
39- When using `bench_with_input`, the input parameter will now be passed through `black_box` before
40  passing it to the benchmark.
41
42## [0.3.6] - 2022-07-06
43### Changed
44- MSRV bumped to 1.49
45- Symbol for microseconds changed from ASCII 'us' to unicode 'µs'
46- Documentation fixes
47- Clippy fixes
48
49## [0.3.5] - 2021-07-26
50
51### Fixed
52
53- Corrected `Criterion.toml` in the book.
54- Corrected configuration typo in the book.
55
56### Changed
57
58- Bump plotters dependency to always include a bug-fix.
59- MSRV bumped to 1.46.
60
61## [0.3.4] - 2021-01-24
62
63### Added
64
65- Added support for benchmarking async functions
66- Added `with_output_color` for enabling or disabling CLI output coloring programmatically.
67
68### Fixed
69
70- Criterion.rs will now give a clear error message in case of benchmarks that take zero time.
71- Added some extra code to ensure that every sample has at least one iteration.
72- Added a notice to the `--help` output regarding "unrecognized option" errors.
73- Increased opacity on violin charts.
74- Fixed violin chart X axis not starting at zero in the plotters backend.
75- Criterion.rs will now automatically detect the right output directory.
76
77### Deprecated
78
79- `Criterion::can_plot` is no longer useful and is deprecated pending deletion in 0.4.0.
80- `Benchmark` and `ParameterizedBenchmark` were already hidden from documentation, but are now
81  formally deprecated pending deletion in 0.4.0. Callers should use `BenchmarkGroup` instead.
82- `Criterion::bench_function_over_inputs`, `Criterion::bench_functions`, and `Criterion::bench` were
83  already hidden from documentation, but are now formally deprecated pending deletion in 0.4.0.
84  Callers should use `BenchmarkGroup` instead.
85- Three new optional features have been added; "html_reports", "csv_output" and
86  "cargo_bench_support". These features currently do nothing except disable a warning message at
87  runtime, but in version 0.4.0 they will be used to enable HTML report generation, CSV file
88  generation, and the ability to run in cargo-bench (as opposed to [cargo-criterion]).
89  "cargo_bench_support" is enabled by default, but "html_reports" and "csv_output"
90  are not. If you use Criterion.rs' HTML reports, it is recommended to switch to [cargo-criterion].
91  If you use CSV output, it is recommended to switch to [cargo-criterion] and use the
92  `--message-format=json` option for machine-readable output instead. A warning message will be
93  printed at the start of benchmark runs which do not have "html_reports" or "cargo_bench_support"
94  enabled, but because CSV output is not widely used it has no warning.
95
96[cargo-criterion]: https://github.com/bheisler/cargo-criterion
97
98## [0.3.3] - 2020-06-29
99
100### Added
101
102- Added `CRITERION_HOME` environment variable to set the directory for Criterion to store
103  its results and charts in.
104- Added support for [cargo-criterion]. The long-term goal here is to remove code from Criterion-rs
105  itself to improve compile times, as well as to add features to `cargo-criterion` that are
106  difficult to implement in Criterion-rs.
107- Add sampling mode option for benchmarks. This allows the user to change how Criterion.rs chooses
108  the iteration counts in each sample. By default, nothing will change for most benchmarks, but
109  very slow benchmarks will now run fewer iterations to fit in the desired number of samples.
110  This affects the statistics and plots generated.
111
112### Changed
113
114- The serialization format for some of the files has changed. This may cause your first benchmark
115  run after updating to produce errors, but they're harmless and will go away after running the
116  benchmarks once.
117
118### Fixed
119
120- Fixed a bug where the current measurement was not shown on the relative regression plot.
121- Fixed rare panic in the plotters backend.
122- Panic with a clear error message (rather than panicking messily later on) when the user sets the
123  group or function name to the empty string.
124- Escape single quotes in benchmark names when generating Gnuplot scripts.
125
126## [0.3.2] - 2020-04-26
127
128### Added
129
130- Added `?Sized` bound to benchmark parameter types, which allows dynamically sized types like
131  `&str` and `&[T]` to be used as benchmark parameters.
132- Added the `--output-format <format>` command-line option. If `--output-format bencher` is passed,
133  Criterion.rs will print its measurements in a format similar to that used by the `bencher` crate
134  or unstable `libtest` benchmarks, and using similar statistical measurements as well. Though this
135  provides less information than the default format, it may be useful for supporting tools which
136  parse this output format.
137- Added `--nocapture` argument. This argument does nothing, but prevents Criterion.rs from exiting
138  when running tests or benchmarks and allowing stdout output from other tests.
139
140### Fixed
141
142- Fixed panic when environment variables contains non-UTF8 characters.
143- Fixed panic when `CRITERION_DEBUG` or `CRITERION_TARGET_DIR` environment variables contain
144  non-UTF8 characters.
145
146## [0.3.1] - 2020-01-25
147
148### Added
149
150- Added new plotting backend using the `plotters` crate. Implementation generously provided by Hao
151  Hou, author of the `plotters` crate.
152- Added `--plotting-backend` command-line option to select the plotting backend. The existing
153  gnuplot backend will be used by default when available, and the plotters backend will be used when
154  gnuplot is not available or when requested.
155- Added `Criterion::plotting_backend()` function to configure the plotting backend in code.
156- Added `--load-baseline` command-line option to load a baseline for comparison
157  rather than measuring the current code
158- Benchmark filters can now be regular expressions.
159
160### Fixed
161
162- Fixed `fibonacci` functions.
163- Fixed `#[criterion]` benchmarks ignoring the command-line options.
164- Fixed incorrect scaling of the violin plots.
165- Don't print the recommended sample count if it's the same as the configured
166  sample count.
167- Fix potential panic when `nresamples` is set too low. Also added a warning
168  against setting `nresamples` too low.
169- Fixed issue where a slow outer closure would cause Criterion.rs to calculate
170  the wrong estimated time and number of iterations in the warm-up phase.
171
172## [0.3.0] - 2019-08-25
173
174### Added
175
176- Added support for plugging in custom measurements (eg. processor counters)
177  into Criterion.rs' measurement and analysis.
178- Added support for plugging in instrumentation for internal profilers such as
179  `cpuprofiler` which must be explicitly started and stopped within the profiled
180  process.
181- Added the `BenchmarkGroup` type, which supersedes `ParameterizedBenchmark`, `Benchmark`,
182  `Criterion::bench_functions`, `Criterion::bench_function_over_inputs`, and `Criterion::bench`.
183  `BenchmarkGroup` performs the same function as all of the above, but is cleaner to use and more
184  powerful and flexible. All of these types/functions are now soft-deprecated (meaning they're
185  hidden from the documentation and should not be used in new code). They will be fully deprecated
186  at some point in the 0.3.\* series and removed in 0.4.0.
187- `iter_custom` - a "timing loop" that allows the caller to perform their own measurements. This is
188  useful for complex measurements that don't fit into the usual mode of calling a lambda in a loop.
189- If the benchmark cannot be completed in approximately the requested measurement time,
190  Criterion.rs will now print a suggested measurement time and sample size that would work.
191- Two new fields, `throughput_num` and `throughput_type` have been added to the `raw.csv` file.
192- Added command-line options to set the defaults for warm-up time, measurement-time, etc.
193
194### Changed
195
196- The `raw.csv` file format has been changed slightly. The `sample_time_nanos` field has been split
197  into `sample_measured_value` and `unit` fields to accommodate custom measurements.
198- Throughput has been expanded from u32 to u64 to accommodate very large input sizes.
199
200### Fixed
201
202- Fixed possible invalid file name error on Windows
203- Fixed potential case where data for two different benchmarks would be stored in the same directory.
204
205### Removed
206
207- Removed the `--measure-only` command-line argument; it was deprecated in favor of `--profile-time`
208  in 0.2.6.
209- External program benchmarks have been removed; they were deprecated in 0.2.6. The new
210  `iter_custom` timing loop can be used as a substitute; see `benches/external_process.rs` for an
211  example of this.
212
213### Deprecated
214
215- The `--test` argument is now deprecated. To test benchmarks, use `cargo test --benches`.
216
217## [0.2.11] - 2019-04-08
218
219### Added
220
221- Enabled automatic text-coloring on Windows.
222
223### Fixed
224
225- Fixed panic caused by outdated files after benchmark names or types were changed.
226- Reduced timing overhead of `Criterion::iter_batched/iter_batched_ref`.
227
228## [0.2.10] - 2019-02-09
229
230### Added
231
232- Added `iter_batched/iter_batched_ref` timing loops, which allow for setup (like
233  `iter_with_setup/iter_with_large_setup`) and exclude drop (like `iter_with_large_drop`) but
234  measure the runtime more accurately, use less memory and are more flexible.
235
236### Deprecated
237
238- `iter_with_setup/iter_with_large_setup` are now deprecated in favor of `iter_batched`.
239
240## [0.2.9] - 2019-01-24
241
242### Changed
243
244- Criterion.rs no longer depends on the default features of the `rand-core` crate. This fixes some
245  downstream crates which use `rand` in a `no_std` context.
246
247## [0.2.8] - 2019-01-20
248
249### Changed
250
251- Criterion.rs now uses `rayon` internally instead of manual `unsafe` code built with thread-scoped.
252- Replaced handlebars templates with [TinyTemplate](https://github.com/bheisler/TinyTemplate)
253- Merged `criterion-stats` crate into `criterion` crate. `criterion-stats` will no longer receive
254  updates.
255- Replaced or removed various other dependencies to reduce the size of Criterion.rs' dependency
256  tree.
257
258## [0.2.7] - 2018-12-29
259
260### Fixed
261
262- Fixed version numbers to prevent incompatibilities between `criterion` and `criterion-stats`
263  crates.
264
265## [0.2.6] - 2018-12-27 - Yanked
266
267### Added
268
269- Added `--list` command line option, which lists the benchmarks but does not run them, to match
270  `cargo test -- --list`.
271- Added README/CONTRIBUTING/LICENSE files to sub-crates.
272- Displays change in throughput in the command-line and HTML output as well as change in iteration
273  time.
274- Benchmarks with multiple functions and multiple values will now generate a per-value summary
275  report file in addition to the existing per-function one.
276- Added a `--profile-time` command-line argument which disables reporting and analysis and instead
277  simply iterates each benchmark for approximately the given number of seconds. This supersedes the
278  (now-deprecated) `--measure-only` argument.
279
280### Fixed
281
282- Functions passed to `Bencher::iter_with_large_setup` can now return output. This is necessary to
283  prevent the compiler from optimizing away the benchmark. This is technically a breaking change -
284  that function requires a new type parameter. It's so unlikely to break existing code that I
285  decided not to delay this for a breaking-change release.
286- Reduced measurement overhead for the `iter_with_large_setup` and `iter_with_drop` methods.
287- `criterion_group` and `criterion_main` macros no longer require the `Criterion` struct to be
288  explicitly imported.
289- Don't panic when `gnuplot --version` fails.
290- Criterion.rs macros no longer require user to `use criterion::Criterion;`
291- Criterion.rs no longer initializes a logger, meaning that it will no longer conflict with user
292  code which does.
293- Criterion.rs no longer fails to parse gnuplot version numbers like
294  `gnuplot 5.2 patchlevel 5a (Gentoo revision r0)`
295- Criterion.rs no longer prints an error message that gnuplot couldn't be found when chart
296  generation is disabled (either by `Criterion::without_plots`, `--noplot` or disabling the
297  HTML reports feature)
298- Benchmark names are now automatically truncated to 100 characters and a number may be added to
299  make them unique. This fixes a problem where gnuplot would crash if the title was extremely long,
300  and also improves the general usability of Criterion.rs.
301
302### Changed
303
304- Changed timing model of `iter_with_large_setup` to exclude time spent dropping values returned
305  by the routine. Time measurements taken with 0.2.6 using these methods may differ from those taken
306  with 0.2.5.
307- Benchmarks with multiple functions and multiple values will now appear as a table rather than a
308  tree in the benchmark index. This is to accommodate the new per-value summary reports.
309
310### Deprecated
311
312- Deprecated the `--measure-only` command-line-argument in favor of `--profile-time`. This will be
313  removed in 0.3.0.
314- External-program benchmarks are now deprecated. They will be removed in 0.3.0.
315- The `html_reports` cargo feature is now deprecated. This feature will become non-optional in 0.3.0.
316- Sample sizes less than 10 are deprecated and will be disallowed in 0.3.0.
317- This is not an exhaustive list - the full scope of changes in 0.3.0 is not yet determined. There
318  may be breaking changes that are not listed here.
319
320## [0.2.5] - 2018-08-27
321
322### Fixed
323
324- Fixed links from generated report files to documentation.
325- Fixed formatting for very large percentage changes (>1000%)
326- Sorted the benchmarks in the index report by name
327- Fixed case where benchmark ID with special characters would cause Criterion.rs to open the wrong
328  file and log an error message.
329- Fixed case where running `cargo clean; cargo bench -- <filter>` would cause Criterion.rs to log
330  an error message.
331- Fixed a GNUplot error message when sample size is very small.
332- Fixed several cases where Criterion.rs would generate invalid path names.
333- Fixed a bug where Criterion.rs would print an error if run with a filter that allowed no benchmarks and a clean target directory.
334- Fixed bug where some benchmarks didn't appear in the benchmark index report.
335- Criterion.rs now honors the `CARGO_TARGET_DIR` environment variable.
336
337### Added
338
339- Criterion.rs will generate a chart showing the effects of changes in input (or input size) for all
340  benchmarks with numeric inputs or throughput, not just for those which compare multiple functions.
341
342## [0.2.4] 2018-07-08
343
344### Added
345
346- Added a pair of flags, `--save-baseline` and `--baseline`, which change
347  how benchmark results are stored and compared. This is useful for
348  working against a fixed baseline(eg. comparing progress on an
349  optimization feature branch to the commit it forked from).
350  Default behavior of Criterion.rs is now `--save-baseline base`
351  which emulates the previous, user facing behavior.
352  - `--save-baseline` saves the benchmark results under the provided name.
353  - `--baseline` compares the results to a saved baseline.
354    If the baseline does not exist for a benchmark, an error is given.
355- Added user-guide documentation for baselines, throughput measurements and
356  plot configuration.
357- Added a flag, `--test`, which causes Criterion to execute the benchmarks once
358  without measuring or reporting the results. This is useful for checking that the
359  benchmarks run successfully in a CI setting.
360- Added a `raw.csv` file to the output which contains a stable, machine-readable
361  representation of the measurements taken by benchmarks. This enables users to
362  perform their own analysis or keep historical information without depending on
363  private implementation details.
364
365### Fixed
366
367- The `sample_size` method on the `Criterion`, `Benchmark` and
368  `ParameterizedBenchmark` structs has been changed to panic if the sample size
369  is less than 2. Other parts of the code require this and will panic if the
370  sample size is 1, so this is not considered to be a breaking change.
371- API documentation has been updated to show more-complete examples.
372- Certain characters will now be replaced with underscores when creating benchmark
373  directory paths, to avoid generating invalid or unexpected paths.
374
375## [0.2.3] - 2018-04-14
376
377### Fixed
378
379- Criterion.rs will now panic with a clear error message if the user attempts to run
380  a benchmark which doesn't call the `Bencher::iter` function or a related function,
381  rather than failing in an uncontrolled manner later.
382- Fixed broken links in some more summary reports.
383
384### Added
385
386- Added a `--measure-only` argument which causes the benchmark executable to run the
387  warmup and measurement and then move on to the next benchmark without analyzing or
388  saving data. This is useful to prevent Criterion.rs' analysis code from appearing
389  in profile data when profiling benchmarks.
390- Added an index report file at "target/criterion/report/index.html" which links to
391  the other reports for easy navigation.
392
393## [0.2.2] - 2018-03-25
394
395### Fixed
396
397- Fixed broken links in some summary reports.
398- Work around apparent rustc bug in >= 1.24.0.
399
400## [0.2.1] - 2018-02-24
401
402### Added
403
404- HTML reports are now a default Cargo feature. If you wish to disable HTML reports,
405  disable Criterion.rs' default features. Doing so will allow compatibility with
406  older Rust versions such as 1.20. If you wish to continue using HTML reports, you
407  don't need to do anything.
408- Added a summary report for benchmarks that compare multiple functions or different
409  inputs.
410
411### Changed
412
413- The plots and HTML reports are now generated in a `report` folder.
414
415### Fixed
416
417- Underscores in benchmark names will no longer cause subscripted characters to
418  appear in generated plots.
419
420## [0.2.0] - 2018-02-05
421
422### Added
423
424- Added `Criterion.bench` function, which accepts either a `Benchmark` or
425  `ParameterizedBenchmark`. These new structures allow for custom per-benchmark
426  configuration as well as more complex benchmark grouping (eg. comparing a Rust
427  function against an external program over a range of inputs) which was not
428  possible previously.
429- Criterion.rs can now report the throughput of the benchmarked code in units of
430  bytes or elements per second. See the `Benchmark.throughput` and
431  `ParameterizedBenchmark.throughput` functions for further details.
432- Criterion.rs now generates a basic HTML report for each benchmark.
433- Added `--noplot` command line option to disable plot generation.
434
435### Changed
436
437- The builder methods on the Criterion struct now take and return self by value
438  for easier chaining. Functions which configure a Criterion structure will need
439  to be updated accordingly, or will need to be changed to work with the
440  `Benchmark` or `ParameterizedBenchmark` types to do per-benchmark configuration
441  instead.
442- The closures taken by `Criterion.bench_*` must now have a `'static` lifetime.
443  This means that you may need to change your closures from `|bencher| {...}`
444  to `move |bencher| {...}`.
445- `Criterion.bench_functions` now takes `I` as an input parameter, not `&I`.
446- Input values must now implement `Debug` rather than `Display`.
447- The generated plots are stored in `target/criterion` rather than `.criterion`.
448
449### Removed
450
451- The hidden `criterion::ConfidenceInterval` and`criterion::Estimate` types are
452  no longer publicly accessible.
453- The `Criterion.summarize` function has been removed.
454
455### Fixed
456
457- Fixed the relative mean and median reports.
458- Fixed panic while summarizing benchmarks.
459
460## [0.1.2] - 2018-01-12
461
462### Changed
463
464- Criterion.rs is now stable-compatible!
465- Criterion.rs now includes its own stable-compatible `black_box` function.
466  Some benchmarks may now be affected by dead-code-elimination where they
467  previously weren't and may have to be updated.
468- Criterion.rs now uses `serde` to save results. Existing results files will
469  be automatically removed when benchmarks are run.
470- Redesigned the command-line output to highlight the important information
471  and reduce noise.
472
473### Added
474
475- Running benchmarks with the variable "CRITERION_DEBUG" in the environment will
476  cause Criterion.rs to generate extra debug output and save the gnuplot scripts
477  alongside the generated plots.
478
479### Fixed
480
481- Don't panic on IO errors or gnuplot failures
482- Fix generation of invalid gnuplot scripts when benchmarking over inputs and inputs include values <= 0.
483- Bug where benchmarks would run one sample fewer than was configured.
484
485### Removed
486
487- Generated plots will no longer use log-scale.
488
489## [0.1.1] - 2017-12-12
490
491### Added
492
493- A changelog file.
494- Added a chapter to the book on how Criterion.rs collects and analyzes data.
495- Added macro rules to generate a test harness for use with `cargo bench`.
496  Benchmarks defined without these macros should continue to work.
497- New contribution guidelines
498- Criterion.rs can selectively run benchmarks. See the Command-line page for
499  more details
500
501## 0.1.0 - 2017-12-02
502
503### Added
504
505- Initial release on Crates.io.
506
507[Unreleased]: https://github.com/bheisler/criterion.rs/compare/0.4.0...HEAD
508[0.1.1]: https://github.com/bheisler/criterion.rs/compare/0.1.0...0.1.1
509[0.1.2]: https://github.com/bheisler/criterion.rs/compare/0.1.1...0.1.2
510[0.2.0]: https://github.com/bheisler/criterion.rs/compare/0.1.2...0.2.0
511[0.2.1]: https://github.com/bheisler/criterion.rs/compare/0.2.0...0.2.1
512[0.2.2]: https://github.com/bheisler/criterion.rs/compare/0.2.1...0.2.2
513[0.2.3]: https://github.com/bheisler/criterion.rs/compare/0.2.2...0.2.3
514[0.2.4]: https://github.com/bheisler/criterion.rs/compare/0.2.3...0.2.4
515[0.2.5]: https://github.com/bheisler/criterion.rs/compare/0.2.4...0.2.5
516[0.2.6]: https://github.com/bheisler/criterion.rs/compare/0.2.5...0.2.6
517[0.2.7]: https://github.com/bheisler/criterion.rs/compare/0.2.6...0.2.7
518[0.2.8]: https://github.com/bheisler/criterion.rs/compare/0.2.7...0.2.8
519[0.2.9]: https://github.com/bheisler/criterion.rs/compare/0.2.8...0.2.9
520[0.2.10]: https://github.com/bheisler/criterion.rs/compare/0.2.9...0.2.10
521[0.2.11]: https://github.com/bheisler/criterion.rs/compare/0.2.10...0.2.11
522[0.3.0]: https://github.com/bheisler/criterion.rs/compare/0.2.11...0.3.0
523[0.3.1]: https://github.com/bheisler/criterion.rs/compare/0.3.0...0.3.1
524[0.3.2]: https://github.com/bheisler/criterion.rs/compare/0.3.1...0.3.2
525[0.3.3]: https://github.com/bheisler/criterion.rs/compare/0.3.2...0.3.3
526[0.3.4]: https://github.com/bheisler/criterion.rs/compare/0.3.3...0.3.4
527[0.3.5]: https://github.com/bheisler/criterion.rs/compare/0.3.4...0.3.5
528[0.3.6]: https://github.com/bheisler/criterion.rs/compare/0.3.5...0.3.6
529[0.4.0]: https://github.com/bheisler/criterion.rs/compare/0.3.6...0.4.0