mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
[zsh] add performance timers
This commit is contained in:
parent
d991810919
commit
7c351c2f22
2 changed files with 44 additions and 5 deletions
|
@ -7,7 +7,13 @@ fi
|
|||
|
||||
source "$ZSH_DOTFILES/zplg.zsh"
|
||||
|
||||
plugin completions 'zsh-users/zsh-completions'
|
||||
_plugin() {
|
||||
_perf_timer_start "plugin $1"
|
||||
plugin "$@"
|
||||
_perf_timer_stop "plugin $1"
|
||||
}
|
||||
|
||||
_plugin completions 'zsh-users/zsh-completions'
|
||||
|
||||
# compinit {{{
|
||||
# note that completion system must be initialized after zsh-completions and
|
||||
|
@ -43,7 +49,7 @@ plugin completions 'zsh-users/zsh-completions'
|
|||
omz_features=(key-bindings termsupport)
|
||||
omz_plugins=(git extract fasd)
|
||||
|
||||
plugin oh-my-zsh 'robbyrussell/oh-my-zsh' \
|
||||
_plugin oh-my-zsh 'robbyrussell/oh-my-zsh' \
|
||||
load='lib/'${^omz_features}'.zsh' \
|
||||
load='plugins/'${^omz_plugins}'/*.plugin.zsh' \
|
||||
before_load='ZSH="$plugin_dir"' \
|
||||
|
@ -54,14 +60,14 @@ plugin completions 'zsh-users/zsh-completions'
|
|||
|
||||
# }}}
|
||||
|
||||
plugin fzf 'junegunn/fzf' build='./install --bin' \
|
||||
_plugin fzf 'junegunn/fzf' build='./install --bin' \
|
||||
after_load='plugin-cfg-path path prepend bin' \
|
||||
after_load='plugin-cfg-path manpath prepend man'
|
||||
|
||||
plugin alias-tips 'djui/alias-tips'
|
||||
_plugin alias-tips 'djui/alias-tips'
|
||||
|
||||
FAST_WORK_DIR="$ZSH_CACHE_DIR"
|
||||
if [[ "$TERM" != "linux" ]]; then
|
||||
plugin fast-syntax-highlighting 'zdharma/fast-syntax-highlighting'
|
||||
_plugin fast-syntax-highlighting 'zdharma/fast-syntax-highlighting'
|
||||
set-my-syntax-theme() { fast-theme "$ZSH_DOTFILES/my-syntax-theme.ini" "$@"; }
|
||||
fi
|
||||
|
|
33
zsh/zshrc
33
zsh/zshrc
|
@ -4,8 +4,39 @@ ZSH_DOTFILES="${0:h}"
|
|||
|
||||
autoload -U colors && colors
|
||||
|
||||
# Performance {{{
|
||||
|
||||
zmodload zsh/datetime
|
||||
typeset -A _perf_timers
|
||||
|
||||
_perf_timer_start() {
|
||||
local name="$1"
|
||||
if [[ -z "$name" ]]; then
|
||||
print >&2 "$0: usage: $0 <name>"
|
||||
return 1
|
||||
fi
|
||||
_perf_timers[$name]="$EPOCHREALTIME"
|
||||
}
|
||||
|
||||
_perf_timer_stop() {
|
||||
local name="$1"
|
||||
if [[ -z "$name" ]]; then
|
||||
print >&2 "$0: usage: $0 <name>"
|
||||
return 1
|
||||
fi
|
||||
local stop_time="$EPOCHREALTIME" start_time="${_perf_timers[$name]}"
|
||||
local -i duration="$(( (stop_time - start_time) * 1000 ))"
|
||||
print -- "\e[${color[faint]}m==>${reset_color} ${name}: ${duration}ms"
|
||||
}
|
||||
|
||||
# }}}
|
||||
|
||||
_perf_timer_start "total"
|
||||
|
||||
for script in functions options path env aliases plugins completion zle prompt colorscheme; do
|
||||
_perf_timer_start "$script.zsh"
|
||||
source "$ZSH_DOTFILES/$script.zsh"
|
||||
_perf_timer_stop "$script.zsh"
|
||||
done
|
||||
|
||||
# add colon after MANPATH so that it doesn't overwrite system MANPATH
|
||||
|
@ -13,4 +44,6 @@ MANPATH="$MANPATH:"
|
|||
|
||||
command_exists rbenv && eval "$(rbenv init -)"
|
||||
|
||||
_perf_timer_stop "total"
|
||||
|
||||
welcome
|
||||
|
|
Loading…
Reference in a new issue