Comparison (do not compare the speeds between the versions of php as
they are on different servers under different loads.) The only
conclusion that I can draw from this so far is that different versions
of php handle these situations differently, newer versions may handle
OOP code better that proc code - this is just conjecture of course.  It
also may not be realistic to judge so harshly and quickly on benchmarks
like this. This kind of code isn't very real world when you get right
down to it. Other factors may also be in play - the kind of functions
used inside the proc/obj, types of variables - how about nested objects
- different kinds of loops - etc etc etc. It's a hard comparison to make
- as I do not have time to compile many versions of php on a given
machine and run the tests at the moment. Maybe someone with a bit of
time to spare would help shed some light on the subject?

If I get a chance I will look into the problem further. And I will have
the results amended to my article on phpbeginner.com (or the results of
the person (people?) who sheds light on the subject for us) so stay
tuned to the website  and I'll try to get something more definitive
soon.

Cheers everyone!

OOP: 
PHP Version: 4.1.2 Took 70.311300992966 seconds
PHP Version: 4.2.1 Took 76.400364041328 seconds
        <?php
        
            set_time_limit(0);
            
            class count {
                function icount($vs) {
                    $var=0;
                    while($count < $vs) {
                        $date=time();
                        $count++;
                    }
                }
            }
            
            function getmicrotime(){
                list($usec, $sec) = explode(" ",microtime());
                return ((float)$usec + (float)$sec);
            }
            
            $time_start = getmicrotime();
            $icount=new count;
            $icount->icount(10000000); 
            $time_end = getmicrotime();
            $time = $time_end - $time_start;
            echo "Took $time seconds";
        ?>

PROC:
PHP Version: 4.1.2 Took 69.567726969719 seconds 
PHP Version: 4.2.1 Took 86.658290982246 seconds
        <?php
        
            set_time_limit(0);
            
            function getmicrotime(){
                list($usec, $sec) = explode(" ",microtime());
                return ((float)$usec + (float)$sec);
            }
            
            function icount($vs) {
                $count=0;
                while($count < $vs) {
                    $count++;
                    $date=time();
                }
            }
            
            $time_start = getmicrotime();
            icount(10000000);
            $time_end = getmicrotime();
            $time = $time_end - $time_start;
            echo "Took $time seconds";
        ?>

-----Original Message-----
From: SP [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, June 27, 2002 12:01 PM
To: Remy Dufour; Kondwani Spike Mkandawire; [EMAIL PROTECTED]
Subject: RE: [PHP] Re: PHP and OOP

Never tested it so I tried it out for the fun of it.  I didn't use yours
but
I used the other guy's code on separate pages and did it ten times.  I
guess
I was wrong, I got around 2% difference.  Definitely not the 20%
difference
that guy got in his.  He was probably using a older version.  Mine was
on
4.1.1 so everyone should be switching to OO from the looks of it.

OO     Procedural
3.22   2.87
3.09   3.05
2.91   3.00
2.88   2.99
3.08   3.09
3.25   3.04
2.97   2.94
2.94   3.01
3.05   2.90
3.07   2.96

3.05   2.99 avg

-----Original Message-----
From: Remy Dufour [mailto:[EMAIL PROTECTED]]
Sent: June 27, 2002 1:34 PM
To: SP; Kondwani Spike Mkandawire; [EMAIL PROTECTED]
Subject: Re: [PHP] Re: PHP and OOP


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



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to