Skip to content

Commit

Permalink
Add with_output_color. Fixes #426
Browse files Browse the repository at this point in the history
  • Loading branch information
bheisler committed Jan 24, 2021
1 parent ffd0313 commit 891d6d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
### Added
- Added support for benchmarking async functions
- Added `with_output_color` for enabling or disabling CLI output coloring programmatically.

### Fixed
- Criterion.rs will now give a clear error message in case of benchmarks that take zero time.
Expand Down
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,13 @@ impl<M: Measurement> Criterion<M> {
self
}

/// Override whether the CLI output will be colored or not. Usually you would use the `--color`
/// CLI argument, but this is available for programmmatic use as well.
pub fn with_output_color(mut self, enabled: bool) -> Criterion<M> {
self.report.cli.enable_text_coloring = enabled;
self
}

/// Set the output directory (currently for testing only)
#[doc(hidden)]
pub fn output_directory(mut self, path: &Path) -> Criterion<M> {
Expand Down

0 comments on commit 891d6d6

Please sign in to comment.