Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86643 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70066 invoked from network); 15 Jun 2015 03:35:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jun 2015 03:35:46 -0000 Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.182 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.160.182 mail-yk0-f182.google.com Received: from [209.85.160.182] ([209.85.160.182:36465] helo=mail-yk0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FE/20-59275-B084E755 for ; Sun, 14 Jun 2015 23:35:42 -0400 Received: by ykaz81 with SMTP id z81so46954080yka.3 for ; Sun, 14 Jun 2015 20:35:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=a5/Oy8IAeZ9O+KhiDAPVn4GpB2U5QTAFBk5Lq2ReT1E=; b=laiH/X9L1GscXRDiNpY7XWCLGQOeOjAver3i2scqCiPL5SQpwLqkxh/m6cPfTTM7NX jgWf7rWY+EqV0d5a8IpGTZhJFa224BtA+CKWerM6ITca3OepxzXZZz6HQsNtV8nL8Sbq haFbW6e3oeTJDnWPmC1JXqwJZzfFotcfRt+ihHetijbbQvyAAlJfRA6UXF+YBjfm+1Kg b1vGt8A294UkVGXzqqvNOKJk0hC5khdqsTS9Li+bwHhmjQFh7dDOJmJ9j8I0oQqrs31p Y007RNENMPcj+l57MChL2JlFdiOHHN9O/7lSn11X4zzdij2Hr5puarRpurfhjY9wqjCW 5Ehg== MIME-Version: 1.0 X-Received: by 10.52.240.198 with SMTP id wc6mr39105715vdc.34.1434339335481; Sun, 14 Jun 2015 20:35:35 -0700 (PDT) Sender: morrison.levi@gmail.com Received: by 10.31.63.130 with HTTP; Sun, 14 Jun 2015 20:35:35 -0700 (PDT) In-Reply-To: References: Date: Sun, 14 Jun 2015 21:35:35 -0600 X-Google-Sender-Auth: _slaLwvRa7Ga_YHAkqkD-N3oMRU Message-ID: To: Yasuo Ohgaki Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Packed array is not fast? From: levim@php.net (Levi Morrison) On Thu, Jun 11, 2015 at 4:21 PM, Yasuo Ohgaki wrote: > 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 How are you testing hash vs packed? As far as what you posted I cannot tell a difference =E2=80=93 it looks like you are running the same thing tw= ice (same binary and same input file).