Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Performance tests of quoting and dequoting, printf -v turned out slow



2018-03-10 09:36:42 +0100, Sebastian Gniazdowski:
[...]
> I only changed method of time measurement in your snippet, and obtained the slowness:
> 
> % typeset -F3 SECONDS=0; INPUT='ice as"program" pick"$ZPFX/bin/prll_(qer|bfr)" src"prll.sh" make"install PREFIX=$ZPFX"'; for ((i = 0; i < 50000; i++)); do printf -v OUTPUT '%q' "$INPUT"; done; echo $SECONDS
> 151.137
[...]
> 
> Not sure what using `time' instead of $SECONDS does, but above method is less suspected of any side effects.
[...]

More importantly here, the difference is that you have that code
interpreted by your interactive shell that has read your
~/.zshrc, while the "time" version starts a new non-interactive
shell that doesn't read ~/.zshrc to interpret the code.

There is probably something in your interactive shell
environment that is causing that.

What do you see, if you run:

(set -x; repeat 5 printf -v x x)

What's the output of:

type printf
trap

Do you get the same behaviour if you run that same code after
"zsh -f" (a new interactive shell instance that doesn't read
your ~/.zshrc)?

-- 
Stephane



Messages sorted by: Reverse Date, Date, Thread, Author