Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a cargo_criterion_support feature flag #541

Open
wants to merge 1 commit into
base: version-0.4
Choose a base branch
from

Conversation

str4d
Copy link

@str4d str4d commented Dec 27, 2021

This enables cargo-criterion support to be compiled out if it is not required. A compile-time error is added to require that at least one of [cargo_bench_support, cargo_criterion_support] must be enabled.

This enables `cargo-criterion` support to be compiled out if it is not
required. A compile-time error is added to require that at least one of
[`cargo_bench_support`, `cargo_criterion_support`] must be enabled.
@str4d str4d mentioned this pull request Dec 27, 2021
Comment on lines +135 to 138
#[cfg(feature = "cargo_criterion_support")]
lazy_static! {
static ref CARGO_CRITERION_CONNECTION: Option<Mutex<Connection>> = {
match std::env::var("CARGO_CRITERION_PORT") {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, when cargo_criterion_support is not enabled, criterion behaves as if cargo-criterion does not exist. It might be useful to check somewhere whether the CARGO_CRITERION_PORT env variable is set, and print a warning or error if cargo_criterion_support is not enabled. This wouldn't be the right place; it would need to go in the benchmark's main function (similar to the previous warnings when cargo_bench_support was not enabled).

@lemmih
Copy link
Collaborator

lemmih commented Dec 28, 2021

I'm not sure what we should do about cargo_bench_support. The benefits of using criterion without cargo bench support seem very minor to me. Unless there is a compelling use-case, I think we should keep cargo_bench_support as a dummy feature that does nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants