mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 08:50:19 +00:00
Add --setup (-s) option, like --prepare but runs once per batch
Add a --setup option for the use-case of wanting to do one-off setup before a set of benchmarks, not the once-per-test setup that --prepare does. This is useful for the cases noted in the updated documentation. Per the feedback on https://github.com/sharkdp/hyperfine/pull/448 this new "--setup" option will steal the "-s" short option from "--style" (initially this was called "--build" and used the non-conflicting "-b"). Potential future work: I'd prefer if this and --cleanup took N number of commands, so you could do e.g.: hyperfine -L rev master,next \ -b 'git worktree add /tmp/test-{r}' \ -b 'make -C /tmp/test-{r} all' \ 'make -C /tmp/test-{r} test' \ -c 'git worktree remove /tmp/test-{r}' I.e. a shortcut around not providing these with &&, which makes things a bit more readable. But the --cleanup option doesn't do that, so let's just go with what it's doing for consistency, so for this you'll now need to do: hyperfine -L rev master,next \ -b 'git worktree add /tmp/test-{r} && make -C /tmp/test-{r} all' \ 'make -C /tmp/test-{r} test' \ -c 'git worktree remove /tmp/test-{r}'
This commit is contained in:
1 parent
abd0d335ab
commit
017d55a4a1
7 files changed
+103
-3
No files matched your search
@@ -70,6 +70,11 @@ impl ExecutionOrderTest {
|
||||
self
|
||||
}
|
||||
|
||||
fn setup(&mut self, output: &str) -> &mut Self {
|
||||
self.arg("--setup");
|
||||
self.command(output)
|
||||
}
|
||||
|
||||
fn prepare(&mut self, output: &str) -> &mut Self {
|
||||
self.arg("--prepare");
|
||||
self.command(output)
|
||||
@@ -147,6 +152,22 @@ fn warmup_runs_are_executed_before_benchmarking_runs() {
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn setup_commands_are_executed_before_each_series_of_timing_runs() {
|
||||
ExecutionOrderTest::new()
|
||||
.arg("--runs=2")
|
||||
.setup("setup")
|
||||
.command("command 1")
|
||||
.command("command 2")
|
||||
.expect_output("setup")
|
||||
.expect_output("command 1")
|
||||
.expect_output("command 1")
|
||||
.expect_output("setup")
|
||||
.expect_output("command 2")
|
||||
.expect_output("command 2")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn prepare_commands_are_executed_before_each_timing_run() {
|
||||
ExecutionOrderTest::new()
|
||||
@@ -181,6 +202,23 @@ fn cleanup_commands_are_executed_once_after_each_benchmark() {
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn setup_prepare_cleanup_combined() {
|
||||
ExecutionOrderTest::new()
|
||||
.arg("--runs=2")
|
||||
.setup("make")
|
||||
.prepare("make testclean")
|
||||
.command("make test")
|
||||
.cleanup("make clean")
|
||||
.expect_output("make")
|
||||
.expect_output("make testclean")
|
||||
.expect_output("make test")
|
||||
.expect_output("make testclean")
|
||||
.expect_output("make test")
|
||||
.expect_output("make clean")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn single_parameter_value() {
|
||||
ExecutionOrderTest::new()
|
||||
|
||||
Reference in new issue
Block a user