Skip to content

Commit

Permalink
feat: add -a (actual time) to zinit times cmd
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
vladdoster committed Apr 25, 2022
1 parent 421855b commit 596f405
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -837,16 +837,16 @@ Following commands are passed to `zinit ...` to obtain described effects.

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

Expand Down
4 changes: 2 additions & 2 deletions doc/zsdoc/zinit-autoload.zsh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
22 changes: 13 additions & 9 deletions zinit-autoload.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -3420,8 +3425,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
Expand Down

0 comments on commit 596f405

Please sign in to comment.