Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add -a (actual time) to zinit times cmd #223

Merged
merged 1 commit into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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