From 450d3c10a8f6728ee8c76bfb99f777658b8d3f35 Mon Sep 17 00:00:00 2001 From: vladislav doster <10052309+vladdoster@users.noreply.github.com> Date: Mon, 25 Apr 2022 01:36:25 -0500 Subject: [PATCH] feat: add `-a` (actual time) to `zinit times` cmd (#223) - Display load moments to `zinit times` via new `-a` flag. I found it useful to show both plugin load times, as well as load moments: Signed-off-by: Vladislav Doster --- README.md | 20 ++++++++++---------- doc/zsdoc/zinit-autoload.zsh.adoc | 4 ++-- zinit-autoload.zsh | 22 +++++++++++++--------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 089e50b9a..d5202fc72 100644 --- a/README.md +++ b/README.md @@ -837,16 +837,16 @@ Following commands are passed to `zinit ...` to obtain described effects. ### Reports and Statistics -| Command | Description | -| :--------------------------------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `times [-s] [-m]` |
Statistics on plugin load times, sorted in order of loading. `-s` – use seconds instead of milliseconds. `-m` – show plugin loading moments.
| -| `zstatus` |
Overall Zinit status.
| -| `report {plg-spec}\|--all` |
Show plugin report. `--all` – do it for all plugins.
| -| `loaded [keyword], list [keyword]` |
Show what plugins are loaded (filter with 'keyword').
| -| `ls` |
List snippets in formatted and colorized manner. Requires **tree** program.
| -| `status {plg-spec}\|URL\|--all` |
Git status for plugin or svn status for snippet. `--all` – do it for all plugins and snippets.
| -| `recently [time-spec]` |
Show plugins that changed recently, argument is e.g. 1 month 2 days.
| -| `bindkeys` |
Lists bindkeys set up by each plugin.
| +| Command | Description | +| :--------------------------------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| ` times [-s] [-m] [-a]` |
Statistics on plugin load times, sorted in order of loading. `-s` – use seconds instead of milliseconds. `-m` – show plugin loading moments. `-a` - show both plugin load times and loading moments
| +| `zstatus` |
Overall Zinit status.
| +| `report {plg-spec}\|--all` |
Show plugin report. `--all` – do it for all plugins.
| +| `loaded [keyword], list [keyword]` |
Show what plugins are loaded (filter with 'keyword').
| +| `ls` |
List snippets in formatted and colorized manner. Requires **tree** program.
| +| `status {plg-spec}\|URL\|--all` |
Git status for plugin or svn status for snippet. `--all` – do it for all plugins and snippets.
| +| `recently [time-spec]` |
Show plugins that changed recently, argument is e.g. 1 month 2 days.
| +| `bindkeys` |
Lists bindkeys set up by each plugin.
| ### Compiling diff --git a/doc/zsdoc/zinit-autoload.zsh.adoc b/doc/zsdoc/zinit-autoload.zsh.adoc index 9cee0d724..1086fe7b0 100644 --- a/doc/zsdoc/zinit-autoload.zsh.adoc +++ b/doc/zsdoc/zinit-autoload.zsh.adoc @@ -814,7 +814,7 @@ ____ User-action entry point. ____ -Has 67 line(s). Doesn't call other functions. +Has 66 line(s). Doesn't call other functions. Called by: @@ -1205,7 +1205,7 @@ ____ User-action entry point. ____ -Has 60 line(s). Calls functions: +Has 65 line(s). Calls functions: .zinit-show-times `-- zinit-side.zsh/.zinit-any-colorify-as-uspl2 diff --git a/zinit-autoload.zsh b/zinit-autoload.zsh index 3f9da54ec..3330ff284 100644 --- a/zinit-autoload.zsh +++ b/zinit-autoload.zsh @@ -2214,22 +2214,27 @@ ZINIT[EXTENDED_GLOB]="" fi [[ -z $EPOCHREALTIME ]] && attime="" + local line="$time" if [[ "$opt" = *-[a-z]#m[a-z]#* ]]; then - time="$attime" + line="$attime" + elif [[ "$opt" = *-[a-z]#a[a-z]#* ]]; then + line="$attime $line" fi + line="$line - $REPLY" + if [[ ${sice[as]} == "command" ]]; then - builtin print "$time" - "$REPLY (command)" + line="$line (command)" elif [[ -n ${sice[sbin]+abc} ]]; then - builtin print "$time" - "$REPLY (sbin command)" + line="$line (sbin command)" elif [[ -n ${sice[fbin]+abc} ]]; then - builtin print "$time" - "$REPLY (fbin command)" + line="$line (fbin command)" elif [[ ( ${sice[pick]} = /dev/null || ${sice[as]} = null ) && ${+sice[make]} = 1 ]]; then - builtin print "$time" - "$REPLY (/dev/null make plugin)" - else - builtin print "$time" - "$REPLY" + line="$line (/dev/null make plugin)" fi + builtin print "$line" + (( sum += ZINIT[$entry] )) done builtin print "Total: $sum sec" @@ -3421,8 +3426,7 @@ EOF —— -h|--help|help – usage information —— man – manual —— self-update – updates and compiles Zinit -—— times [-s] [-m] – statistics on plugin load times, sorted in order of loading; -s – use seconds instead of milliseconds, -m – show plugin loading moments -—— zstatus – overall Zinit status +—— zstatus – overall Zinit statu—— times [-s] [-m] [-a] – statistics on plugin load times, sorted in order of loading; -s – use seconds instead of milliseconds, -m – show plugin loading moments, -a – show both load times and loading moments —— load ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – load plugin, can also receive absolute local path —— light [-b] ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – light plugin load, without reporting/tracking (-b – do track but bindkey-calls only) —— unload ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – unload plugin loaded with \`zinit load ...', -q – quiet