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
Resolves #565 - "Conclude phase (opposite of --prepare)"
This is an implementation of
--conclude
argument where--conclude
is implemented in the same manner as--prepare.
Example usage
hyperfine --warmup 1 --runs 2 --prepare 'echo prepare >> test.txt' --conclude 'echo conclude >> test.txt' 'sleep 0.5'
Output
(In hindsight I should have also echoed command here in between prepare and conclude. The example output under Example Command Output does this)
Relevant tests have been added and relevant docs updated.
Discussion
I'm very open to PR feedback and I don't mean to appear out of nowhere and force this change on anyone. I do think the --conclude option makes a lot of sense. I found the codebase for this project quite approachable after coming across it in https://nnethercote.github.io/perf-book/benchmarking.html and I thought attempting this PR would be a good educational exercise.
This was quite straight-forward to implement using existing --prepare code as a template and I naturally ended up with a solution basically identical to what @shoffmeister had linked in a comment in the issue thread.
Despite prepare and conclude implementions being almost identical (and setup and cleanup not far off either) I'm not sure about the payoff for coming up with some abstraction which increases code reuse between them.
I can't imagine there ever being a need to introduce another execution scheduling option beyond
setup/prepare/conclude/cleanup
. The Cypress test runner in javascript land only has BeforeAll, Before, After, AfterAll for running extra code around tests. The Cypress naming scheme could be support for future aliases for this functionality which are of the formbefore-*,after-*
.Any major benefit from additional work I think would be in maintainability and the current code seems readable enough to me as is (although that's subjective).
I did see this is in the hyperfine 2.0 milestone list though so it's possible there are already plans for this issue which are such a rework and fix problems I'm just not thinking of since I'm not familiar enough.
New tests
Example Command Output
Below is example output of running the release build of hyperfine build from this PR with setup/prepare/conclude/cleanup arguments all being passed.