Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93640 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4445 invoked from network); 30 May 2016 20:22:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 May 2016 20:22:24 -0000 Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.47 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 74.125.82.47 mail-wm0-f47.google.com Received: from [74.125.82.47] ([74.125.82.47:37789] helo=mail-wm0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8B/F1-26200-EF0AC475 for ; Mon, 30 May 2016 16:22:23 -0400 Received: by mail-wm0-f47.google.com with SMTP id z87so82913157wmh.0 for ; Mon, 30 May 2016 13:22:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=HuYADkc/sjNO3hfUhg92HMfU/EM1sAjSBJuo1rxsCPg=; b=YKVarTTZipxypmq+bPzucayu1Y8KATAky7TjbZ8+Wn19WVJaR8vWOeiivYk1bWub0c Vb8WavkX8qDC8gbsInj3ZvugdN1yYY51QGMZhKUbqXmzR+SKjlHRtw2iFUe/ZyZYSZpO i+qgbyyvxd9OTy9Y72t1LWNf7Q0r4eiB1LK5133/rWnQgxxB9aSZUQ0/4zH+Mq0i8wdA fFBHGagHM8eXr5/rP33utlTRg/pVQ1P+6gnBnRCxxMBGuoPaMV35XLawGuPJMzss0GqE xA5i+Ts3uWI0LPf6oNrE39sSZjDCd7A5P1Pc2xq0JyLIqXcRbZe23rntlC/+RivBEOo6 R/Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=HuYADkc/sjNO3hfUhg92HMfU/EM1sAjSBJuo1rxsCPg=; b=DQVWl85gYZ5gbAqqCul5A6YwbHdVRpDWXPTUlPiuHLI4fnQrQdGoaQL+UsXINdhn08 laxB/5U0JcaK1pChbEWx6XbuX0Y0qkyCrhHYuFT9asrJ2AYbg+VZODAv+q+SBnHc0gva HMWT2Cz3RlMtaN4NsbFIsLd89hs31C2+7cVk9sUWuWxTY2c46D0Y+xhUl7/5S1bWFBVi IY5ZK0Hzi8GjzsC+89kgUMOFDmH4wD1GgfHNlYDrxXeKCeevEZ0I3xbuXhdG+k3UwNkD egL8tp1ou0/GL+eB4orNUGnrQo2p1yFcFPBmT2yGW1ymsbAp8730o+0n2uNCPCzGAGPQ oSrA== X-Gm-Message-State: ALyK8tIHBnW7aLh0UPfPVJtCZf8L1H3ZTalh4QgS0yNnR8Yf1+Tv2FD1+UZZeRSCdWY4HgfLZ09IQauDo1wF9g== X-Received: by 10.28.157.23 with SMTP id g23mr12954686wme.34.1464639739564; Mon, 30 May 2016 13:22:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.163.106 with HTTP; Mon, 30 May 2016 13:21:59 -0700 (PDT) In-Reply-To: References: Date: Mon, 30 May 2016 22:21:59 +0200 Message-ID: To: Nikita Popov Cc: "Colin O'Dell" , PHP Internals , Jeremy Mikola Content-Type: multipart/alternative; boundary=001a114ba6e466994f05341503ce Subject: Re: [PHP-DEV] [RFC Discussion] array_change_keys() From: ocramius@gmail.com (Marco Pivetta) --001a114ba6e466994f05341503ce Content-Type: text/plain; charset=UTF-8 I benchmarked this more carefully at https://github.com/Ocramius/array_change_keys-benchmark - the results are indeed not matching what is represented in the RFC. Specifically, `array_change_keys` has performance that is comparable to `array_combine` + `array_map`, and looping is still faster by at least 35%. This is mostly due to the function calls, which is what I expected. Feel free to patch the benchmarks, should they be buggy. Also feel free to add more scenarios. Cheers, Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 30 May 2016 at 20:55, Nikita Popov wrote: > On Mon, May 30, 2016 at 3:40 AM, Colin O'Dell > wrote: > >> Marco, >> >> >> > 1. could you also provide the code for the benchmarks? I'd gladly >> measure >> > them with an accurate tool >> > >> >> Yeah that would be great! Here's the benchmark I was using: >> https://gist.github.com/colinodell/872c1f0c92351af687347c0c8be4f253 > > > I can't tell you what exactly this is benchmarking (probably a mix of > various caches ranging from the Zend MM, via the kernel, to the CPU). The > only thing it's pretty certainly not benchmarking are different > implementations of changing keys :) You're basically just penalizing > whichever implementation comes first. > > For a more representative benchmark, reduce the number of elements by a > factor of 10 or hundred. In which case foreach should win at least against > the array_map+array_combine implementation. > > Regards, > Nikita > --001a114ba6e466994f05341503ce--