To continue on with the previous post, On the speed of functions and namespaces, it was brought to my attention that namespaces should be faster with aliasing. Also how does it compare to static functions? The news was not good for either. Another thing that was brought to my attention that to avoid a lookup when in a namespace functions like filter_var should be absolute referenced, so we/I tried that too.

posts with the tag: performance
On the speed of functions and namespaces…
My day started off fairly simple, I wanted to write a function that could take a string of things like “True” and “Yes” and return boolean true, thusly “False” and “No” would return me boolean false. PHP has a function that can handle the basics of this already, filter_var, however it only works on variants of true and false, not yes or no. Keeping with PHP’s strtolower and strtoupper naming I named this function strtobool and stuck it in my utility function namespace.
I then compared it speedwise to the built-in filter_var function, even though filter_var cannot do what I want at the scope I want it – it would still be a good test to see if it was even worth supporting “Yes” and “No”. Here are the results of that test.
Continue reading about the speed of PHP functions and namespaces