-
-
Notifications
You must be signed in to change notification settings - Fork 362
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
--output
overwrites previous commands and runs
#529
Comments
Thank you for your feedback! The Note that it's rather easy to get the desired functionality if you simply redirect the output yourself: hyperfine "ls > ls.log" "pwd > pwd.log" As for the per-iteration output, you could use hyperfine \
--setup "rm -f ls.log" \
--prepare "echo --- >> ls.log" \
"ls >> ls.log" If you want a new logfile for every run, I'm sure there would be workarounds as well, but I guess they won't be as concise as the commands suggested above. As for your feature requests:
I can see how there might be cases where one would like to use
This might be helpful in general, so we could think about setting e.g. hyperfine "ls > ls-{#}.log" Another option would be to inject an environment variable, similar to how we already set hyperfine "ls > ls-${HYPERFINE_ITERATION}.log" |
Indeed this is actually what I have been doing so far, the only issue lies in that multiple iterations are either overwritten or get appended, which can be pretty annoying to parse out with very long outputs even if you mark them. An injected I am fine with the idea that I appreciate the consideration, and thank you for this awesome tool |
Ok. I believe that should be easy to implement.
This is of course a very valid point. Sorry that I discarded that point above.
Hm. That's also not the best user experience, right? I think we should go with your "multiple Another option which might be easier to implement but with an arguably worse UX would be to show a (nice) error message in case |
I think we should keep a couple things in mind:
Are there compelling use cases other than debugging? Maybe a
|
Is the overwriting Vs. appending such a large difference that it matters over a more reasonable/expected UX? How is overwriting output every time useful? From my perspective the only reason it has any use at all at the moment is that a failed test run will kill hyperfine and leave the failed runs log behind. Logging the last command of a series of runs as it currently does is practically useless for anything other than a run failure. If that's the only usecase of writing output to file it should be renamed to If possible, using a not-insignificant write buffer and flushing between runs would be better for "consistency" than anything if that were a big deal to someone.
Personally I'm apathetic to such an argument. I think that's user error. It might be detectable/something you can warn against but similar results can already be achieved by
My use case is being able to try and examine statistical anomalies in the debug output. Being able to go back and see that a particular run for one reason or another bailed out of a hotpath, or retried is useful to me even beyond "debugging" what went wrong. Knowing why a set of tests took significantly longer might not even be "debugging" but normal operation of said program. Another potential usecase is determining if a particular run is successful even if the exit code is 0. I know of a few obtuse applications that can fail but not report that as an exit code. Right now I don't know of a way that can be determined with hyperfine other than writing output. |
Maybe not. I just did some local benchmarking and
For me, the purpose of
Me too, actually I've kind of changed my mind on this one because $ hyperfine --output=null fd --output=./file fd is an interesting benchmark.
This makes a lot of sense to me actually. I usually use Anyway, here's what I think now. Supporting $ hyperfine --output=./file find fd # Both to ./file right now
$ hyperfine find --output=./file fd # Does --output apply to fd or both?
$ hyperfine find fd --output=./file # Does --output apply to anything? I agree we should clarify in the documentation that For examining the output, I think we should recommend using shell redirections, and provide I also think something like |
I was simply going to assume the same semantics as |
Ok, I think we're all on the same page. To summarize:
|
My 2 cents after finding out that |
To be clear, I would like us to implement all of the four points listed in my previous comment. That would include an improved |
I just ran into this myself, and everything here makes sense, though I do have an alternative suggestion (especially since this issue hasn't been updated in just over 2 years). How would we feel about adding an extra flag to switch the file output behaviour that's only valid when To provide some context, what I'm currently benchmarking is a https://vitest.dev/ configuration, and the output includes an internal breakdown of how much CPU time different phases of the runner took.
And this is the current
|
Task one from my list is now completed (see #772) |
Currently I'm working on a set of benchmarks where I want to save the output of (at least) one run from each.
--output
should arguably be allowed N times, where N is the number of commands being benchmarked.However, I would also argue that keeping each runs output is extremely useful, specifically for debugging/figuring out why statistical outliers exist.
As an arbitrary example:
will only show output from a single
pwd
. Passing multiple outputs does not work, as hyperfine only expects one.As a proposal for how this could change there are two things that would be nice to see:
--prepare
is allowed per commandFor short running commands like
ls
this is a problem as it may run somewhere in the neighborhood of 5k times, so it may be a problem to create a new logfile for each run. Longer running commands obviously do not have this problem.The text was updated successfully, but these errors were encountered: