Re: Re: PHP and OOP
| From: | Remy Dufour | Date: | Thu, 27 Jun 2002 17:34:09 +0000 |
| Subject: | Re: Re: PHP and OOP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-104191@lists.php.net to get a copy of this message | ||
I've tested thecode and there is what i've got
Proceduraltook 1.24408602715 seconds
OOtook 1.24240803719 seconds
Here is the code. Test it by yourself
<?php function getmicrotime(){ list($usec, $sec) = explode("
",microtime()); return ((float)$usec + (float)$sec); } function
icount($vs) { $var=0; while($count < $vs) {
$count++; } } $time_start = getmicrotime(); icount(1000000);
echo "Procedural<br> took ". (getmicrotime() - $time_start) ."
seconds<br>";
class count { function icount($vs) { $var=0;
while($count < $vs) { $count++; } } }
$time_start = getmicrotime(); $icount = new count;
$icount->icount(1000000); echo "<br>OO<br> took ". (getmicrotime() -
$time_start) ." seconds";?>
> OO is slower then procedural. You can test that out yourself or look at
> this article where the guy did a very basic test. Maybe they will fix the
> speed problem by the time php5 comes around.
> http://www.phpbeginner.com/columns/demitrious/objects/8