Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86601 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7713 invoked from network); 11 Jun 2015 22:22:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jun 2015 22:22:06 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.195 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.160.195 mail-yk0-f195.google.com Received: from [209.85.160.195] ([209.85.160.195:35788] helo=mail-yk0-f195.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4D/21-31453-C0A0A755 for ; Thu, 11 Jun 2015 18:22:06 -0400 Received: by ykq19 with SMTP id 19so966667ykq.2 for ; Thu, 11 Jun 2015 15:22:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=df4yZCoVoRV7GzVfjMZClV8RE3pQj4770xeSynAVoL0=; b=pL0G8zT0aeByF49z9mcVBp2H3T+3hPH+pRpD4AtVDQvN02t/ANz0yxxVPzJdHonWSj XhuXJsJyW8j1PzElnUFzyahoJOKRswTNvFwN6NQ7KteYkRmTlGHYUB82N3R/y4HUR6jU fR9AG3nRNk14MMJxmcdkHCfjPa6ZuLimDwFeWnVM54J2Zp4f/qVBLPfe5vqh5DedHtC6 wcHWu6G1C3iDyK3cutFzjiwhnbBFZDpmC2GKLD0zwnv+eKFIw6/EgaW0QHy12Un60CyI xlQkOLJNizV8fKpWPqqQlBvCVKDbrl1VcsSMrvMk/UBqLeK+zfkLvik15NU+E+DAuyih IuCg== X-Received: by 10.129.98.132 with SMTP id w126mr14779063ywb.32.1434061321760; Thu, 11 Jun 2015 15:22:01 -0700 (PDT) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.13.246.2 with HTTP; Thu, 11 Jun 2015 15:21:21 -0700 (PDT) Date: Fri, 12 Jun 2015 07:21:21 +0900 X-Google-Sender-Auth: I3je_7_hpYnVmGVwqBzOQotj9lc Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1146c7f2ab73fc0518456be6 Subject: Packed array is not fast? From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a1146c7f2ab73fc0518456be6 Content-Type: text/plain; charset=UTF-8 Hi all, I've tried to see how packed array is faster with following code http://3v4l.org/TQd6c I confirmed when start index is non-zero, hash is used by zend_hash_index_find(). I got following result. (with much larger number of elements/loops) Fedora 22 + current master without --enable-debug 1st "Time" is total execution time. 2nd "Time" is the time spent by "for loop" Hash [yohgaki@dev php-src]$ ./php-bin ~/tmp/array_bench2.php Time: 1.7903809547424 Time: 1.1529920101166 [yohgaki@dev php-src]$ ./php-bin ~/tmp/array_bench2.php Time: 1.8049499988556 Time: 1.1719739437103 Packed [yohgaki@dev php-src]$ ./php-bin ~/tmp/array_bench2.php Time: 1.7407248020172 Time: 1.1594388484955 [yohgaki@dev php-src]$ ./php-bin ~/tmp/array_bench2.php Time: 1.7248120307922 Time: 1.1530420780182 Packed array is not so fast, even if zend_hash.c seems much faster with packed array. Just FYI. Regards, P.S. Am I doing something wrong? HHVM seems to have optimization margins for hash and loop. -- Yasuo Ohgaki yohgaki@ohgaki.net --001a1146c7f2ab73fc0518456be6--