July 27th, 2005

Working on the computer, Working

Some PHP profiling results

I was just doing some profiling code in PHP so I figured I would share the results.

if-else is better than $var = (condition) ? true : false; 2/3 of the time. Tested 30 times at 2,000,000 times each. Difference was negligable in all cases.

using list() = each() is better than foreach() if you process the same array more than once, otherwise foreach() is better at least 3/4 of the time.
Turns out this was an error on my part. foreach() automatically resets the array before it starts, while list() = each() doesn't, thus in my code it said "We're at the end. We're done already" and stopped. After adding a manual reset() the foreach() code was always faster.

foreach() is better than for()'ing through array_keys() 29 times out of 30. Last time was probably due to hiccup in system.

You can download the profiler code here. It's set up to allow you to add a couple of functions and then compare their execution time X number of times (10 being default X). Very simple.
(updated file on server to reflect changes in code)
  • Current Music
    "Universe" by Savage Garden
Distressed, Tombo - Distressed

This is what the 'standard' means to me.

I am getting utterly sick at hearing "That isn't allowed in the standard" or "That's depreciated in the standard". Well if your dang standards actually let me do what I want to do, and reliably between browsers, then I wouldn't have a problem follow the standard.

As it is I can't even get a div to center itself without setting a static width or an image to vertically align itself according to the contents of the div. I spent two hours yesterday searching and trying everything I could find and think of with little to no success. The only reliable way to do it is with a table, yet those are getting yelled at because they don't follow the standard, yet there isn't a reliable replacement!

Add to that I recently got flamed for not using the EM font size 'standard', yet when I changed over to what looked right in my browser (I needed a static font size because the area in which the page displays is less than 640x480) nearly everyone else had a hissy fit because it was too big in their browsers. Apparently I'm nearly the only one who thinks 14 is too big of a default font and changed my browser to 12, so when I set 1em it looks fine to me, but looks too big to them. Go figure.

Screw the standard! I'll design my pages the way I know they'll work.

I'm not going to put up with any of this "And when the old way isn't supported any more you'll have to redesign your pages" bull idiot nonsense because as it is the standard isn't being correctly supported now! It'd break for more people if I did it correctly than if I did it the old way.

Screw them, I say.
  • Current Music
    "Hold Me" By Savage Garden