* Brace expansion performance
@ 2010-03-22 16:24 Radoulov, Dimitre
2010-03-22 17:03 ` Nikolai Weibull
2010-03-22 17:22 ` Bart Schaefer
0 siblings, 2 replies; 3+ messages in thread
From: Radoulov, Dimitre @ 2010-03-22 16:24 UTC (permalink / raw)
To: zsh-users
Hi all,
does anybody know why the zsh brace expansion (?) performs so ...
differently?
[1]
% time ksh -c 'echo ${.sh.version};for i in {1..300000}; do :;done'
Version JM 93t+ 2009-05-01
0.50s user 0.24s system 90% cpu 0.817 total
% time bash -c 'echo $BASH_VERSION;for i in {1..300000}; do :;done'
4.0.33(1)-release
1.59s user 0.58s system 90% cpu 2.409 total
% time zsh -c 'print $ZSH_VERSION $ZSH_PATCHLEVEL;for i in {1..300000};
do :;done'
4.3.10 1.4705
15.26s user 5.24s system 87% cpu 23.468 total
[2]
$ time ksh -c 'echo ${.sh.version};for i in {1..300000}; do :;done'
Version M 1993-12-28 r
real 0m0.886s
user 0m0.873s
sys 0m0.014s
$ time bash -c 'echo $BASH_VERSION;for i in {1..300000}; do :;done'
3.1.17(1)-release
real 0m2.482s
user 0m2.463s
sys 0m0.019s
$ time zsh -c 'print $ZSH_VERSION $ZSH_PATCHLEVEL;for i in {1..300000};
do :;done'
4.2.6
real 0m47.353s
user 0m46.672s
sys 0m0.629s
Tested on VirtualBox Ubuntu 9.10 guest [1] and on a real RHEL 5.1 host[2].
Best regards
Dimitre
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Brace expansion performance
2010-03-22 16:24 Brace expansion performance Radoulov, Dimitre
@ 2010-03-22 17:03 ` Nikolai Weibull
2010-03-22 17:22 ` Bart Schaefer
1 sibling, 0 replies; 3+ messages in thread
From: Nikolai Weibull @ 2010-03-22 17:03 UTC (permalink / raw)
To: Radoulov, Dimitre; +Cc: zsh-users
On Mon, Mar 22, 2010 at 17:24, Radoulov, Dimitre <cichomitiko@gmail.com> wrote:
> does anybody know why the zsh brace expansion (?) performs so ...
> differently?
Ouch.
Zsh is faster for
for (( i = 1; i <= 300000; i++ )); do :; done,
though.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Brace expansion performance
2010-03-22 16:24 Brace expansion performance Radoulov, Dimitre
2010-03-22 17:03 ` Nikolai Weibull
@ 2010-03-22 17:22 ` Bart Schaefer
1 sibling, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2010-03-22 17:22 UTC (permalink / raw)
To: zsh-users
On Mar 22, 5:24pm, Radoulov, Dimitre wrote:
}
} does anybody know why the zsh brace expansion (?) performs so ...
} differently?
First make sure "zsh -c" isn't reading some expensive init files that
bash/ksh aren't, but:
I'm pretty sure zsh is actually allocating an array of 300000 integers
during expansion of that expression, and probably copying it a few times.
schaefer[633] strace bash -c 'echo $BASH_VERSION;echo $BASH_VERSION;for i in {1..300000}; do :;done' |& wc
322 1262 17792
schaefer[634] strace Src/zsh -fc 'echo $ZSH_VERSION;for i in {1..300000}; do :;done' |& wc
901381 5408181 43590584
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-22 17:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-22 16:24 Brace expansion performance Radoulov, Dimitre
2010-03-22 17:03 ` Nikolai Weibull
2010-03-22 17:22 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).