Re: Re: array_change_key_case()? key_exists()?
| From: | Jeroen van Wolffelaar | Date: | Mon, 12 Nov 2001 00:23:10 +0000 |
| Subject: | Re: Re: array_change_key_case()? key_exists()? | ||
| References: | 1 | Groups: | php.dev php.doc |
| Request: | Send a blank email to phpdoc+get-969338736@lists.php.net to get a copy of this message | ||
On Mon, 12 Nov 2001, Jeroen van Wolffelaar wrote:
> the loop overhead itself. I'm now creating such a test, to see the real
> difference.
Which is quite impressive. On a 486 test machine, running 100 times this
function over an array of 25 items with 6 character long keys, I get
these results:
array_change_key_case(), minus loop overhead: 0.1s
foreach in userland, minus loop overhead: 0.95s
Meaning that array_change_key_case is more than 9 times faster. Trying
to track down where the performance issue is:
the foreach loop itself: 0.41s
the strtoupper alone: 0.15s (2.5 times more than array_change_keys()!)
So the rest is probably in adding a key to an array, variable assiging,
etc.
There seems to be only one conclusion possible - array_change_key_case()
is a lot faster than userland implementation.
So there probably should be array_change_key_case() or an alternative
to adress this performance issue, as it seems to be general php overhead
causing this huge difference (runtime resolving of function calls,
runtime resolving of variable names, etc etc).
--Jeroen