How I debugged my slow bash startup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start a new shell | |
... startup: 31 | |
... git-completion: 113 | |
... git-prompt: 41 | |
... exports: 47 | |
... rbenv: 216 | |
... other scripts: 41 | |
~$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print_timing(){ | |
func_start=$1 | |
func_label=$2 | |
# func_end=$(date +%s%3N) | |
func_end=$(python -c 'from time import time; print int(round(time() * 1000))') | |
echo ... $func_label: $(( func_end-func_start )) | |
start=$func_end | |
} | |
start=$(python -c 'from time import time; print int(round(time() * 1000))') | |
print_timing $start "startup" | |
# some chunk of stuff | |
print_timing $start "first chunk" | |
# initialize my PS1 which got slow and hairy | |
print_timing $start "ps1" | |
# rbenv is pretty slow | |
print_timing $start "rbenv" | |
# load nvm because holy cow it's slow | |
print_timing $start "nvm" | |
# other scripts last | |
[[ -f ~/.bash_profile.local ]] && source ~/.bash_profile.local | |
[[ -f ~/.bash_aliases ]] && source ~/.bash_aliases | |
[[ -f ~/.bashrc ]] && source ~/.bashrc | |
print_timing $start "other scripts" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment