4 ms·
A good way to isolate which work is causing slowness is the PS4 variable. This is what is printed in "-x" tracing mode. E.g.: PS4='+$EPOCHREALTIME ' zsh
by cb321 4y ago
A good way to isolate which work is causing slowness is the PS4 variable. This is what is printed in "-x" tracing mode. E.g.:
PS4='+$EPOCHREALTIME ' zsh -ilx -c exit 2>/t/zpro
You need to have `zmodload zsh/datetime` loaded early for that to work..E.g. at the very top of your .zshenv.
It's not hard to do a little post-processing script to have awk do entry-to-entry deltas on that /t/zpro file and then sort those to get a "seconds cmd" kind of report. Personally, I have found this more effective at identifying hotspots than the zprof mentioned in the article.
EDIT: Caveat - There can be a bit of a Heisenberg style disturb what you are measuring effect from trace overheads. For example, the `_comps = (32 kiB report)` always shows up as the most expensive thing for me, but I think that 3.3ms comes mostly from the `-x` just printing the thing out after the timestamp or maybe formatting it for print. If I just do a t0=$EPOCHREALTIME before and echo $[EPOCHREALTIME-t0] after it takes only 1.0 ms in non-traced mode. So, 2.3/3.3 = 70% of the time is just the formatting/printing/-x work.