3 ms·
Like many other people, I use oh-my-zsh for default setup and that's it. I literally use a single plugin for git and very actively autoload my custom functions
by alkh 9mo ago
Like many other people, I use oh-my-zsh for default setup and that's it. I literally use a single plugin for git and very actively autoload my custom functions to avoid startup delay. With my 384 line config and oh-my-zsh on, here are the results:
$ hyperfine -N "zsh -lc 'exit 0'" "zsh -c 'exit 0'"
Benchmark 1: zsh -lc 'exit 0'
Time (mean ± σ): 54.5 ms ± 6.3 ms [User: 10.2 ms, System: 14.3 ms]
Range (min … max): 38.1 ms … 64.9 ms 78 runs
Benchmark 2: zsh -c 'exit 0'
Time (mean ± σ): 6.5 ms ± 1.4 ms [User: 0.8 ms, System: 1.3 ms]
Range (min … max): 3.9 ms … 14.2 ms 424 runs
It's crazy how their startup time is 380 ms, and I suspect something else might be the reason, not just oh-my-zsh
- jabwd 9mo agoTrying doing the benchmark in a git repo.
- alkh 9mo agoThat's where I actually did it, by coincidence
- baby 9mo agoYou should try extract, z, and fzf
- maple3142 9mo agoI think `zsh -l` start a login shell, which does not load zshrc so oh-my-zsh don't get initialized. Try `zsh -ic exit` and it should load zshrc before executing exit. That said, the time of `zsh -ic exit` isn't really meaningful metric for measuring the performance of an interactive shell. See https://github.com/romkatv/zsh-bench#how-not-to-benchmark https://github.com/romkatv/zsh-bench#how-not-to-benchmark for details.
- alkh 9mo agoValid points, I learned something new today. Thanks, you were right. If using -ic flags I am getting around 300 ms... Interesting how I never noticed, guess I don't open many terminal during the day
- archargelod 9mo agoBetter way to benchmark zsh startup time is with zprof. Add this to your ~/.zshrc: zmodload zsh/zprof .. rest of your zsh config .. zprof And then restart terminal.
- simonair 9mo agoFor anyone who cares about zsh startup performance, `zsh4humans` by `romkatv` (author of powerlevel10k) is worth a look: https://github.com/romkatv/zsh4humans https://github.com/romkatv/zsh4humans It achieves instant startup by rendering the prompt before the full shell initializes. Since adopting it, I am done fiddling with my shell config and the fact that `zsh4humans` is in maintenance-mode is actually an advantage as it keeps me from wasting time refactoring `zshrc`.