Shut up operator @ slowing script down

Submitted by tomek on Sun, 05/08/2011 - 13:55

f2 is slower than f1 by 310.16% (3.1 times slower)

Full source code as executed.
define('LOOP',1000000);
function a() {};
function f1() {
  for($i=0; $i<LOOP; ++$i) {
    a();
    a();
    a();
    a();
    a();
  }
}
function f2() {
  for($i=0; $i<LOOP; ++$i) {
    @a();
    @a();
    @a();
    @a();
    @a();
  }
}
 
$start = microtime(true);
f1();
$stop = microtime(true);
$time1 = $stop - $start;
 
$start = microtime(true);
f2();
$stop = microtime(true);
$time2 = $stop - $start;
 
echo $time1 . "\t";
echo $time2 . "\n";
Test results
comparisontime1time2php_version
329.53%193512183119075.3.5-1ubuntu7.2
516.67%145691989843465.3.3-7
589.72%2288894157869315.3.5-1ubuntu7.2
487.2%147612986678845.3.3-7+squeeze1
336.04%2675751166737php-5.3.6-phpbrew_compiled
353.86%2514781141366php-5.3.7-phpbrew_compiled
350.87%2487741121644php-5.3.8-phpbrew_compiled
368.37%2523401181896php-5.3.9-phpbrew_compiled
359.99%2535581166354php-5.3.10-phpbrew_compiled
332.07%2512601085610php-5.3.11-phpbrew_compiled
332.84%2516741089340php-5.3.12-phpbrew_compiled
331.27%2513161083851php-5.3.13-phpbrew_compiled
341.27%2580841138851php-5.3.14-phpbrew_compiled
326.92%2567601096165php-5.3.15-phpbrew_compiled
375.22%2570231221431php-5.3.16-phpbrew_compiled
323.93%2585671096138php-5.3.17-phpbrew_compiled
332.24%2652831146665php-5.3.18-phpbrew_compiled
335.79%2658711158635php-5.3.19-phpbrew_compiled
199.24%191803573955php-5.4.0-phpbrew_compiled
191.32%204048594436php-5.4.1-phpbrew_compiled
192.3%208688609993php-5.4.2-phpbrew_compiled
191.09%204464595181php-5.4.3-phpbrew_compiled
192.47%196194573806php-5.4.4-phpbrew_compiled
203.21%194489589709php-5.4.5-phpbrew_compiled
198.43%195571583637php-5.4.6-phpbrew_compiled
198.93%193136577339php-5.4.7-phpbrew_compiled
205.01%196894600549php-5.4.8-phpbrew_compiled
188.56%207120597661php-5.4.9-phpbrew_compiled
50%
updown
50%