Page 1 of 1
phpbench.com
Posted: Fri Jun 06, 2008 10:32 am
by pickle
This looks interesting - some interesting revelations:
http://www.phpbench.com/
Re: phpbench.com
Posted: Tue Jun 10, 2008 12:26 pm
by Mordred
Wow, so much work into so flawed a setup...
Apart from comparing apples to oranges, he sometimes compares apples to friday.
I'm far from impressed.
Re: phpbench.com
Posted: Tue Jun 10, 2008 12:32 pm
by pickle
How is it flawed? I'm not going to say I think it's perfect, but he seems to be doing a pretty decent job of comparing multiple ways of doing the same thing.
Re: phpbench.com
Posted: Tue Jun 10, 2008 12:50 pm
by Mordred
Well, look carefully at the snippets he compares - most often than not, they are simply not equivalent, up to the point of being radically different
and
Code: Select all
$key = array_keys($aHash);
$size = sizeOf($key);
for ($i=0; $i<$size; $i++) $tmp[] = $aHash[$key[$i]];
And look at this little gem:
Code: Select all
while($i < 2000) {
isSet($notSet);
is_array($notSet);
++$i;
}
Wow, eight times slower than isset(), seriously! How about a nice cup of the && operator?
And what is this supposed to mean:
Code: Select all
class SomeClass2 {
function f() {
}
}
...
$obj =& $someClass->f();
Tests need to be done with real code, not with empty loops and empty functions. Data should be read and written to, not merely aliased. Ideally, standalone scripts should be generated and called from an "outside" loop, just like they would be executed in the real life.
Re: phpbench.com
Posted: Tue Jun 10, 2008 12:53 pm
by superdezign
Well, at least the website is pretty. :/
I just feel as though it's a bit.. random. He doesn't seem to be trying to prove any point in particular, and it doesn't really give me any idea into what to and not to do, especially after seeing the details that ~Mordred has pointed out.
Re: phpbench.com
Posted: Tue Jun 10, 2008 11:48 pm
by Bill H
Well, at least the website is pretty. :/
Degustibus non disputandum est.
Re: phpbench.com
Posted: Fri Jun 13, 2008 10:20 am
by RobertGonzalez
In all cases I've found that the foreach loop is substantially faster than both the while() and for() loop procedures. One thing to note is that when using an entire loop from the start it's extremely good to use the reset() function in all examples
Nevermind the fact the foreach makes a copy of the array in a all cases. And because of that, reset() means nothing to it.
I personally think his comparisons are crap. He should the same exact array and process them in the exact same manner (barring the loop construct of course), doing this many times over to get a clean average.
He should also post the resources that are on the machine he is testing with.
Re: phpbench.com
Posted: Fri Jun 13, 2008 10:57 am
by onion2k
While the tests do seem to demonstrate (in a flawed manner) that there can be speed differences between logically similar things, he has ignored things like resource usage and code readability. One method might well be a couple of hundred microseconds faster, but if it's using 5 times the RAM it might not be a very sensible saving on a busy site. Likewise, a snippet might save you a little CPU time but if it's at the expensive of having readable, maintainable code, is it really worth doing?
Re: phpbench.com
Posted: Fri Jun 13, 2008 11:20 am
by Eran
In my opinion this is a nice reference to have when the time comes for extreme optimization. In some edge cases it could be useful, like when fetching massive result sets that need to be iterated etc.