Skip to content

Instantly share code, notes, and snippets.

@elentok
Created October 10, 2013 20:34
Show Gist options
  • Save elentok/6925233 to your computer and use it in GitHub Desktop.
Save elentok/6925233 to your computer and use it in GitHub Desktop.
Profiling zshrc (to find slow scripts)
typeset -F SECONDS=0
export START_TIME=$SECONDS
if [ -e ~/.profiling ]; then
echo "zshrc started"
source() {
local before=$SECONDS
. $*
local duration=$((($SECONDS - $before) * 1000))
echo "$(printf '%7.2f' $duration)ms $*"
}
fi
# INIT CODE HERE
# show total load time
duration=$((($SECONDS - $START_TIME) * 1000))
echo "\033[1;30m($(printf '%.2f' $duration)ms)\033[0m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment