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

benchmark runner is passed --bench even when harness = false #3027

Closed
bluss opened this issue Aug 21, 2016 · 4 comments · Fixed by #12850
Closed

benchmark runner is passed --bench even when harness = false #3027

bluss opened this issue Aug 21, 2016 · 4 comments · Fixed by #12850
Labels
C-bug Category: bug Command-bench S-propose-close Status: A team member has nominated this for closing, pending further input from the team

Comments

@bluss
Copy link
Member

bluss commented Aug 21, 2016

I'm experimenting with benchmarking for Rust stable. One way to tie into cargo is simply to use the benchmark facility:

[[bench]]
name = "benchmarks"
harness = false

This compiles and runs, using a dev-dependency in the benchmark runner and so on. The only unexpected part is that it is passed --bench as a command line argument (and to add to that, it's not the first argument but the last). I'd expect it does not use --bench when harness = false.

@alexcrichton
Copy link
Member

Sounds reasonable to me! Unfortunately this won't be trivial to implement in Cargo, but the info's all there in one way or another, just need to connect the dots.

@epage epage added the S-propose-close Status: A team member has nominated this for closing, pending further input from the team label Oct 6, 2023
@epage
Copy link
Contributor

epage commented Oct 6, 2023

Could you clarify what the downside is to --bench being passed in?

At this point, this seems like doing so would break backwards compatibility and I'd propose to the cargo team we close this. There might be ways to make a transition for this (already for other issues, I want to offer ways to control the protocol between cargo and harnesses) but that is moving in the direction of opting into more requirements on harnesses, not less, and any work in this direction would come at a cost of time and complexity.

@bluss
Copy link
Member Author

bluss commented Oct 7, 2023

It's a while since I worked with this, but I think the gist of it is that for harness = false it's a custom program that can have its own command line interface. I think the user should be able to define this interface, or at least the mandatory parts of it (enforced --bench) should be documented.

If any of that is now documented and so on, I don't know now though. 🙂

@weihanglo
Copy link
Member

weihanglo commented Oct 18, 2023

or at least the mandatory parts of it (enforced --bench) should be documented.

This sounds a preferable plan to me, though I found it already documented: https://doc.rust-lang.org/nightly/cargo/commands/cargo-bench.html#description

Cargo passes the --bench flag to the test harness to tell it to run only benchmarks.

I think we can add something like "regardless of whether the harness is libtest or a custom harness.", at the end of the sentence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug Command-bench S-propose-close Status: A team member has nominated this for closing, pending further input from the team
Projects
Development

Successfully merging a pull request may close this issue.

5 participants