More benchmark - #1500
Open
dalonsoa wants to merge 7 commits into
Open
Conversation
Co-authored-by: Alex Dewar <alexdewar@users.noreply.github.com>
Collaborator
|
This looks like it could be useful (at least for some things). Two comments:
|
Collaborator
Author
|
This approach is called I've no idea why the warnings, to be honest. I also noticed it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Proof of concept of conditional compilation to use unstable features during benchmarking. For reference, check:
Ignore the whole diff - I do not know why it is not picking it right. Just check 71fa007
When running
cargo testor any other normal command, it will drop any code related to thefeature = bench, and hence it will work fine.When running
cargo bench --features bench, the code will not be dropped, and compilation will fail, because the stable version of rust does not supportfeature(test)and all the bench stuff.To make it run, we need to indicate we are using the nightly version of the compiler, using
cargo +nightly bench --features bench. With this, it will run the benchmarks we had before, within thebenchdirectory and using all the features ofCriterion, as well as the much simpler#[bench]benchmarks. For the example I've added, it will just print:Among all the other output. No graphs or comparison with previous runs, but might be enough for many cases.
Note that the benchmark code is isolated in its own module, not within
mod testslike in the example, such that it can be conditionally excluded/included during compilation.Fixes # (issue)
Type of change
Key checklist
$ cargo test$ cargo docpresent in the previous release
Further checks