From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12944 invoked by alias); 25 Mar 2011 00:37:51 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 15891 Received: (qmail 26921 invoked from network); 25 Mar 2011 00:37:49 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at myproxylists.com designates 217.119.39.74 as permitted sender) X-Originating-IP: 127.0.0.1 Message-ID: <5c830d92034e61a01c96e6aa4d10798c.squirrel@gameframe.net> Date: Fri, 25 Mar 2011 02:37:45 +0200 Subject: Why large arrays are extremely slow to handle? From: nix@myproxylists.com To: zsh-users@zsh.org User-Agent: SquirrelMail/1.4.20 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal 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. --- 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.