Fun link I found: http://www.php.lt/benchmark/phpbench.php It compares a lot of different methods such as single vs double quotes, if/else vs switch, and it updates all the values when you load the page so it's actually doing it when you view the page. Interesting read for any PHP gurus or guys who are into high traffic sites. The most interesting thing I found was precalculating the max value in a standard for() loop, if you do for ($i=0; $i<$size; $i++) it's a lot faster having already determined $size vs for ($i=0; $i<count($array); $i++) or sizeOf(). I loaded it up a couple of times and got 6-8x difference. Enjoy!
What other comparisons did you want to see? I wrote something like this to test switch vs. if/else and stumbled across this article while trying to find more sources, it's not hard to write these, just need to figure out what you want to test.
Well, that's a basic programming method you should follow on every language. It's a trivial optimizing technique like using function arguments by reference instead of by copy.
pretty good, but nothing ensure that other things (OS, etc...) changed the executions times while the bench was running but we can also take this in consideration...
A lot of that is considered "trivial optimizing", but certain things like predetermining your the max value in a for loop the difference is rather large, and when you're looking at a server with high load and having a large number of visitors, it does matter quite a bit. I've got a couple of things I'll be working on all day, but if I find some time I'll definitely try those out. My guess would be that while() is marginally faster and that fetching an array would be almost identical to fetching an array.
mysql_fetch_array() with default type parameter gets an array twice as large as the one returned by mysql_fetch_row() as it gets string and numeric keys for each result. It would be interesting to know what the actual difference between associative and numeric types are as I have assumed that associative results are worth the slight performance hit for the added convenience.
And this is why I made my previous comment =/ Don't say "default type parameter", say "SELECT *", which shouldn't be used for publicly accessible stuff, you should ALWAYS use SELECT col1,col2,col3,colx, otherwise you're grabbing twice as much code, and you're also forcing mysql to run an extra query to grab the names of the columns.
Selecting all columns with SELECT * should not be done in most cases, obviously, but why did you point this out here? If you are confused about me pointing out a "default type parameter", then maybe you were unaware I was referring to the second optional parameter of mysql_fetch_array()
I assumed from your comment, had you already known that bit of information you would have also known that in the php man it says that there is no significant speed difference.