phpbench.com
Moderator: General Moderators
phpbench.com
This looks interesting - some interesting revelations: http://www.phpbench.com/
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: phpbench.com
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.
Apart from comparing apples to oranges, he sometimes compares apples to friday.
I'm far from impressed.
Re: phpbench.com
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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: phpbench.com
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
And look at this little gem:
Wow, eight times slower than isset(), seriously! How about a nice cup of the && operator?
And what is this supposed to mean:
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.
Code: Select all
foreach($aHash as $val);Code: Select all
$key = array_keys($aHash);
$size = sizeOf($key);
for ($i=0; $i<$size; $i++) $tmp[] = $aHash[$key[$i]];Code: Select all
while($i < 2000) {
isSet($notSet);
is_array($notSet);
++$i;
}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.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: phpbench.com
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.
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.
- Bill H
- DevNet Resident
- Posts: 1136
- Joined: Sat Jun 01, 2002 10:16 am
- Location: San Diego CA
- Contact:
Re: phpbench.com
Degustibus non disputandum est.Well, at least the website is pretty. :/
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: phpbench.com
Nevermind the fact the foreach makes a copy of the array in a all cases. And because of that, reset() means nothing to it.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
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
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
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.