Re: [RFC Discussion] array_change_keys()

From: Date: Mon, 30 May 2016 20:21:59 +0000
Subject: Re: [RFC Discussion] array_change_keys()
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-93640@lists.php.net to get a copy of this message
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 <nikita.ppv@gmail.com> wrote: > On Mon, May 30, 2016 at 3:40 AM, Colin O'Dell <colinodell@gmail.com> > 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 >

« previous php.internals (#93640) next »