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 <mvdoster@gmail.com>
This commit is contained in:
vladislav doster 2022-04-25 01:36:25 -05:00 committed by GitHub
parent bad7af3ae2
commit 450d3c10a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 21 deletions

View file

@ -837,16 +837,16 @@ ### Tracking of the Active Session
### Reports and Statistics
| Command | Description |
| :--------------------------------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `times [-s] [-m]` | <div align="justify" style="text-align: justify;"> Statistics on plugin load times, sorted in order of loading. `-s` use seconds instead of milliseconds. `-m` show plugin loading moments.</div> |
| `zstatus` | <div align="justify" style="text-align: justify;"> Overall Zinit status.</div> |
| `report {plg-spec}\|--all` | <div align="justify" style="text-align: justify;"> Show plugin report. `--all` do it for all plugins.</div> |
| `loaded [keyword], list [keyword]` | <div align="justify" style="text-align: justify;"> Show what plugins are loaded (filter with 'keyword').</div> |
| `ls` | <div align="justify" style="text-align: justify;"> List snippets in formatted and colorized manner. Requires **tree** program.</div> |
| `status {plg-spec}\|URL\|--all` | <div align="justify" style="text-align: justify;"> Git status for plugin or svn status for snippet. `--all` do it for all plugins and snippets.</div> |
| `recently [time-spec]` | <div align="justify" style="text-align: justify;"> Show plugins that changed recently, argument is e.g. 1 month 2 days.</div> |
| `bindkeys` | <div align="justify" style="text-align: justify;"> Lists bindkeys set up by each plugin.</div> |
| Command | Description |
| :--------------------------------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| ` times [-s] [-m] [-a]` | <div align="justify" style="text-align: justify;"> 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</div> |
| `zstatus` | <div align="justify" style="text-align: justify;"> Overall Zinit status.</div> |
| `report {plg-spec}\|--all` | <div align="justify" style="text-align: justify;"> Show plugin report. `--all` do it for all plugins.</div> |
| `loaded [keyword], list [keyword]` | <div align="justify" style="text-align: justify;"> Show what plugins are loaded (filter with 'keyword').</div> |
| `ls` | <div align="justify" style="text-align: justify;"> List snippets in formatted and colorized manner. Requires **tree** program.</div> |
| `status {plg-spec}\|URL\|--all` | <div align="justify" style="text-align: justify;"> Git status for plugin or svn status for snippet. `--all` do it for all plugins and snippets.</div> |
| `recently [time-spec]` | <div align="justify" style="text-align: justify;"> Show plugins that changed recently, argument is e.g. 1 month 2 days.</div> |
| `bindkeys` | <div align="justify" style="text-align: justify;"> Lists bindkeys set up by each plugin.</div> |
### Compiling

View file

@ -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

View file

@ -2214,22 +2214,27 @@ ZINIT[EXTENDED_GLOB]=""
fi
[[ -z $EPOCHREALTIME ]] && attime="<no zsh/datetime module → no time data>"
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