Created
October 10, 2013 20:34
-
-
Save elentok/6925233 to your computer and use it in GitHub Desktop.
Profiling zshrc (to find slow scripts)
This file contains hidden or 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
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