Karol Grecki wrote:

Colin Guthrie-6 wrote:
Having done some basic benchmarks, on this thread:
http://thread.gmane.org/gmane.comp.php.general/190070
the second example above gave me a ~3.5x speed increase. If there is a 2-depth array that needs checking then it yielded a ~4.5x speed increase.

This would seem like a fairly easy "low hanging fruit" optimisation that could be made in the ZF with minimum of hassle.

That's all good but if calls to array_key_exists() amount to ~0% of total
request time then 4x ~0% is still ~0%. In the meantime you can shed as much
as 10%, 20%... by removing actual bottlenecks. Optimisation without
profiling is just a waste of time and even if changes are easy to make, risk
of introducing bugs may not be worth it.

Oh, indeed. My only check here was the number of calls to this contained in the ZF codebase and I didn't do any specific profiling on how often this actually comes into it.

In my current use of ZF, we're only just beginning to roll it out into wider use, and to profile my use case would probably not be overly useful. I just think that the use of array_key_exists() vs. isset()/empty() is mostly a coding style thing (some people prefer one or the other or simply don't know the consequences), and by highlighting it here, hopefully less new calls can be added and some of the older, oft called instances can be converted to give a performance gain.

I'm just making an observation here. People who are more involved in core development can judge whether or not it would make a difference :)

Col



--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

Reply via email to