Reply to Re: Constructor as a "Reset" Button

Your name:

Reply:


Posted by Rik on 07/25/07 17:27

On Wed, 25 Jul 2007 18:56:08 +0200, Sanders Kaufman <bucky@kaufman.net> =
=

wrote:

> Michael Fesser wrote:
>> .oO(Sanders Kaufman)
>>
>>> What you guys are doing here is - you're asking me to make the =

>>> application LESS efficient in order to conform to your herd mentalit=
y.
>> It is as efficient as yours, but more stable.
>
> So - making two function calls in PHP uses no more resources than maki=
ng =

> one? I don't buy it.

It is negligable. And it assures compatibility, as stated before: the fa=
ct =

you can call the constructor like a normal method in the present situati=
on =

is not something to be relied upon.

FYI:
<?php
class A{
var $foo;
function A(){
$this->foo =3D 'bar';
}
}
class B{
var $foo;
function B(){
$this->init();
}
function init(){
$this->foo =3D 'bar';
}
}
$start =3D microtime(true);
for($i =3D 1;$i<500;$i++){
$void =3D new A();
}
$middle =3D microtime(true);
for($i =3D 1;$i<500;$i++){
$void =3D new B();
}
$end =3D microtime(true);
echo 'A:',($middle-$start),"\n";
echo 'B:',($end-$middle),"\n";
?>

Result:
A:0.001378059387207
B:0.0017580986022949

And that is on my homebox, entirely not optimised for this kind of thing=
.. =

500 instantiations. I really don't care about the difference here..
-- =

Rik Wasmus

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация