Has anyone tried the following examples that supposedly show how much slower
php OOP is? I have tried the examples and the OOP program actually runs a
fraction quicker (Windows 2000 system, Apache 1.3.24 and php 4.1.2 as CGI)? I have written quite a lot of OOP code, is there a considerable speed difference?
<?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);
$time_end = getmicrotime();
$time = $time_end - $time_start;
echo "Took $time seconds";
?>
<?php
class count {
function icount($vs) {
$count=0;
while($count < $vs) {
$count++;
}
}
}
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();
$icount=new count;
$icount->icount(1000000);
$time_end = getmicrotime();
$time = $time_end - $time_start;
echo "Took $time seconds";
?>