zsh-users
 help / color / mirror / code / Atom feed
* why is (F) about twice as fast as print -l ?
@ 2023-02-06  4:15 sergio
  2023-02-06  5:03 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: sergio @ 2023-02-06  4:15 UTC (permalink / raw)
  To: zsh-users


l=({1..100000000})

% for i in {1..3}; do time (print ${(F)l} > /dev/null); done
( print ${(F)l} > /dev/null; )  12.08s user 0.35s system 99% cpu 12.473 
total
( print ${(F)l} > /dev/null; )  11.89s user 0.35s system 99% cpu 12.283 
total
( print ${(F)l} > /dev/null; )  11.99s user 0.37s system 99% cpu 12.414 
total

% for i in {1..3}; do time (print -l $l > /dev/null); done
( print -l $l > /dev/null; )  22.11s user 2.90s system 99% cpu 25.044 total
( print -l $l > /dev/null; )  22.00s user 3.12s system 99% cpu 25.160 total
( print -l $l > /dev/null; )  22.15s user 3.01s system 99% cpu 25.216 total


-- 
sergio.


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

* Re: why is (F) about twice as fast as print -l ?
  2023-02-06  4:15 why is (F) about twice as fast as print -l ? sergio
@ 2023-02-06  5:03 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2023-02-06  5:03 UTC (permalink / raw)
  To: sergio; +Cc: zsh-users

On Sun, Feb 5, 2023 at 8:15 PM sergio <sergio@outerface.net> wrote:
>
> l=({1..100000000})

${(F)l} joins this huge array into a single string and then that
single argument is passed to "print".

print -l $l expands the array and passes all those words to "print",
requiring that they individually be copied at least one extra time.

Incidentally,
  print -aC1 $l
is even slower, but
  printf "%s\n" $l
is about the same as print -l.


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

end of thread, other threads:[~2023-02-06  5:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-06  4:15 why is (F) about twice as fast as print -l ? sergio
2023-02-06  5:03 ` 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).