zsh-users
 help / color / mirror / code / Atom feed
* Why large arrays are extremely slow to handle?
@ 2011-03-25  0:37 nix
  2011-03-25  0:46 ` Mikael Magnusson
  2011-03-25  2:29 ` Bart Schaefer
  0 siblings, 2 replies; 5+ messages in thread
From: nix @ 2011-03-25  0:37 UTC (permalink / raw)
  To: zsh-users

Tested on AMD Phenom(tm) II X6 1090T Processor 3.6GHz using one core.

I think there's is a big flaw somewhere that causes the following:

#!/bin/zsh

emulate zsh

TEST=()

for i in {1..10000} ; do

TEST+="$i" # append (push) to an array

done

--- 10K
time ./bench
real    0m3.944s

--- 50K BOOOM! WTF?

time ./bench
real    1m53.321s

Does not make much sense to me. Im also a PHP developer. Just for
comparison, let's do the same with PHP.

<?php

$test = array();

for ($i=1; $i < 50000; $i++) {

$test[] = $i;

}

print_r($test);

?>

--- 10K

time php TEST_PHP
real    0m0.011s

--- 50K

time php TEST_PHP
real    0m0.025s


Any ideas why it's extremely slow? I have need to use very large arrays
(even over one million elements in a single array) but it's currently
impossible due to the above.





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

end of thread, other threads:[~2011-03-25  2:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-25  0:37 Why large arrays are extremely slow to handle? nix
2011-03-25  0:46 ` Mikael Magnusson
2011-03-25  1:12   ` nix
2011-03-25  2:29 ` Bart Schaefer
2011-03-25  2:50   ` nix

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