php - Why does a method call slows down everything? -


i have small loop new object.

for ($i = 0; $i < $ilen; $i++) {     $time = microtime(true);     $row = db_row($res, $i);     echo "(" . ($i + 1) . " / " . $ilen . ") ";     $element = new datastructureelement($row['code']);     $elementt = $element->gettypeclass();     unset($element);     $elementt->setname($row['name']); // bad line!     unset($elementt);     echo number_format((microtime(true) - $time) * 1000, 1) . 'ms ';     echo "\n"; } 

if leave out "bad line" got results:

(1 / 3000) 1.7ms (2 / 3000) 0.7ms (3 / 3000) 2.4ms (4 / 3000) 1.9ms (5 / 3000) 0.7ms (6 / 3000) 0.7ms (7 / 3000) 3.2ms (8 / 3000) 2.1ms (9 / 3000) 0.7ms (10 / 3000) 0.7ms (11 / 3000) 0.7ms (12 / 3000) 0.7ms (13 / 3000) 0.7ms ... (2995 / 3000) 0.6ms (2996 / 3000) 0.5ms (2997 / 3000) 0.6ms (2998 / 3000) 0.7ms (2999 / 3000) 0.5ms (3000 / 3000) 0.5ms

but if don't this:

(1 / 3000) 1.5ms (2 / 3000) 0.6ms (3 / 3000) 6.6ms (4 / 3000) 2.3ms (5 / 3000) 1.3ms (6 / 3000) 1.2ms (7 / 3000) 3.7ms (8 / 3000) 2.3ms (9 / 3000) 1.4ms (10 / 3000) 1.3ms (11 / 3000) 1.3ms (12 / 3000) 1.5ms (13 / 3000) 1.2ms ... (2995 / 3000) 14.2ms (2996 / 3000) 14.3ms (2997 / 3000) 13.8ms (2998 / 3000) 13.9ms (2999 / 3000) 14.2ms (3000 / 3000) 14.7ms

and that's how bad method looks like:

public function setname($name) { /*     i've deleted usefull stuff writing database      track down problem. nothing changed in behavior. */ } 

i'm out of ideas ... don't ask unsets. new objects have same impact if aren't distroyed afterwards.

php version: 5.3.2-1ubuntu4.20 (this version can use. can not upgrade/update. installing newer version under plesk hard hell , maybe wouldn't solve problem.)

thank :)


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -