for i in $(seq 1 10); do /usr/bin/time zsh -i -c exit; done
Add this to the start of your ~/.zshrc
:
zmodload zsh/zprof
And this to the end:
zprof
Or if you want to play around with the output dump it in a file:
zprof > ~/dev/dotfiles/profiling.txt
Commands ZSH spent most of the time are at the top of the output.
compaudit
& compinit
are the slowest ones in my case.
Compinit is a function that initializes shell completion. After some googling I found out that the problem might be "too big"
.zcompdump
file, in my case it was about 1mb, so I deleted it (this file is autogenerated), and ZHS magically started to be faster.
This is something I will do as well.
After that I have added deleting this file to my user startup script.
Reference: How to debug zsh startup time
autoloa -Uz compinit
if [ $(date +'%j') != $(stat -f '%Sm' -t '%j' ~/.zcompdump) ]; then
compinit
else
compinit -C
fi
source ~/.antibody_plugins.sh
Reference: