zsh-users
 help / color / mirror / code / Atom feed
From: nix@myproxylists.com
To: zsh-users@zsh.org
Subject: Why large arrays are extremely slow to handle?
Date: Fri, 25 Mar 2011 02:37:45 +0200	[thread overview]
Message-ID: <5c830d92034e61a01c96e6aa4d10798c.squirrel@gameframe.net> (raw)

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.





             reply	other threads:[~2011-03-25  0:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-25  0:37 nix [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5c830d92034e61a01c96e6aa4d10798c.squirrel@gameframe.net \
    --to=nix@myproxylists.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).