Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Shell startup, aliases vs. functions vs. autoloadable functions, and zcompile benefits

On 11/30/21, Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx> wrote:
> On Tue, Nov 30, 2021 at 3:30 AM Zach Riggle <zachriggle@xxxxxxxxx> wrote:
>> The benchmark I used
>> $ hyperfine 'zsh -i -l "exit 0"'
>> Obviously this is not the BEST benchmark [for checking shell startup
>> time]
> Obviously. It's the worst or at least a strong contender for the title.

I think it's fine to do this (assuming he actually meant -i -l -c
"exit 0" (missing -c in the quoted command)), if you don't do any
weird stuff in your startup files (like you mention in your "how not
to benchmark" section). Assuming your startup files are synchronous,
the above will tell you how long it takes to execute your init file
plus some other overhead, so if you do something and the number is
lower, the thing you did will indeed make startup faster. If your
startup files are not synchronous, then obviously nothing I said
applies and everything you say is true. BTW, the above command can
easily be improved for worseness:
% time (repeat 1000; zsh -ic exit)

> Since you care about interactive zsh performance, at least skim
> through the homepage of zsh-bench. It'll save you time.

% ./zsh-bench
==> benchmarking login shell of mikaelh ...
zsh-bench: cannot find prompt; make sure it contains hostname or the
last part of the current directory

Sadly no time was saved :(.

Mikael Magnusson

Messages sorted by: Reverse Date, Date, Thread, Author