His series of articles ("top php programming mistakes") is great, and
I've heard good things about his "PHP Cookbook" but Hughes is way off
here. There is some additional overhead with OO code but there is *very*
little difference in speed (less than 5% in synthetic benchmarks, and
much less in more complex php code) - certainly not the "signigicant slow
down" that he claims.
IIRC, later in the article series, Hughes admits he isn't an OO fan, so
he's probably a bit biased. Maybe he knows of some case where OO PHP code
runs really slow, but since he doesn't present any data to back up his
claims I suspect he just guessed that OO PHP would be slow (ie - he made
it up!).
I don't use OO for everything I do, but if the project is going to be over
1000 lines or so, I find OO code easier to maintain. YMMV.
For testing, I used two simple test files that both printed "hello
world" five times. I did the benchmarking with ab (apache
bench). The OO one:
<?php
class bench {
function test () {
print "hello world!";
}
}
$bo = new bench;
$bo->test();
$bo->test();
$bo->test();
$bo->test();
$bo->test();
?>
The non-OO version is the same, but without the class stuff. The non-OO
version averaged 580 req/s, while the OO version averaged 550 req/s. This
was on a 600mhz pIII with 256megs of ram running Apache 1.3.19 and PHP
4.0.5 on a Linux 2.4.3 kernel.
Regards,
Sean
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]