We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
It can't test shell aliases and function, can it? :)
The text was updated successfully, but these errors were encountered:
bash
Bash functions can easily be benchmarked by exporting them:
$ sleep1() { sleep 1; } $ export -f sleep1 $ hyperfine sleep1 Benchmark #1: sleep1 Time (mean ± σ): 1.005 s ± 0.003 s [User: 3.4 ms, System: 1.7 ms] Range (min … max): 1.001 s … 1.009 s 10 runs
As for aliases, I don't think there is a way to export them. But you can always put the alias or shell function into a separate file:
alias
export
echo 'alias my_alias="sleep 1"' > /tmp/my_alias.sh hyperfine 'source /tmp/my_alias.sh; eval my_alias'
Note that this needs to be an absolute path and that you have to use eval to expand my_alias only after my_alias.sh has been parsed.
eval
my_alias
my_alias.sh
zsh
In zsh, exporting functions is not supported (by design). You would have to put the function or alias in a file as well:
echo 'my_function() { sleep 1 }' > my_function.zsh hyperfine --shell zsh 'source my_function.zsh; eval my_function'
We should probably document this somewhere in the README
Sorry, something went wrong.
Thanks! (I'm not closing this since you mentioned probably adding these hints to the documentation but feel free to close if needed.)
Successfully merging a pull request may close this issue.
It can't test shell aliases and function, can it? :)
The text was updated successfully, but these errors were encountered: