zsh-users
 help / color / mirror / code / Atom feed
* Performance numbers on "if [" vs. "[" alone vs. "if [[" vs. "[[" alone
@ 2016-09-16  7:23 Sebastian Gniazdowski
  2016-09-16 10:18 ` Sebastian Gniazdowski
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Gniazdowski @ 2016-09-16  7:23 UTC (permalink / raw)
  To: Zsh Users

% zsh-5.2 -f

===> if [ "$a" = "1" ]

typeset -F SECONDS; SECONDS=0; repeat 100000; do if [ "$a" = "1" ];
then echo yes; fi; done; echo $SECONDS
1.0209490000


===> [ "$a" = "1" ]

typeset -F SECONDS; SECONDS=0; repeat 100000; do [ "$a" = "1" ] &&
echo yes; done; echo $SECONDS
0.6701160000


===> if [[ "$a" = "1" ]]

typeset -F SECONDS; SECONDS=0; repeat 100000; do if [[ "$a" = "1" ]];
then echo yes; fi; done; echo $SECONDS
0.5131310000


===> [[ "$a" = "1" ]]

typeset -F SECONDS; SECONDS=0; repeat 100000; do [[ "$a" = "1" ]] &&
echo yes; done; echo $SECONDS
0.0925930000


Best regards,
Sebastian Gniazdowski


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-09-17  7:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-16  7:23 Performance numbers on "if [" vs. "[" alone vs. "if [[" vs. "[[" alone Sebastian Gniazdowski
2016-09-16 10:18 ` Sebastian Gniazdowski
2016-09-17  4:17   ` Bart Schaefer
2016-09-17  6:24     ` Sebastian Gniazdowski
2016-09-17  7:39   ` Sebastian Gniazdowski

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).