Unused method parameters

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

f2 is slower than f1 by 78.69%

Full source code as executed.
define('LOOP',10000000);
 
function a($arg1) {};
function b($arg1, $arg2=null, $arg3=null, $arg4=null) {};
 
function f1() {
  for($i=0; $i<LOOP; ++$i) {
    a(1);  
  }
}
 
function f2() {
  for($i=0; $i<LOOP; ++$i) {
    b(1);  
  }
}
 
$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
68.97%8751292147869075.3.5-1ubuntu7.2
65.98%8943673148444265.3.3-7
71.09%13810184236282465.3.5-1ubuntu7.2
60.7%8974626144221985.3.3-7+squeeze1
84.63%12430492295085php-5.3.6-phpbrew_compiled
71.11%12342312111933php-5.3.7-phpbrew_compiled
71.41%12088342072048php-5.3.8-phpbrew_compiled
67.18%12234422045307php-5.3.9-phpbrew_compiled
72.75%12050142081674php-5.3.10-phpbrew_compiled
66.89%12335912058721php-5.3.11-phpbrew_compiled
66.49%12339472054414php-5.3.12-phpbrew_compiled
66.51%12356172057378php-5.3.13-phpbrew_compiled
71.23%12393492122120php-5.3.14-phpbrew_compiled
67.94%12551942107990php-5.3.15-phpbrew_compiled
82.02%12474872270615php-5.3.16-phpbrew_compiled
69.1%12271962075139php-5.3.17-phpbrew_compiled
84.09%12309862266139php-5.3.18-phpbrew_compiled
69.11%12418802100166php-5.3.19-phpbrew_compiled
102.72%8024751626797php-5.4.0-phpbrew_compiled
74.84%10033651754289php-5.4.1-phpbrew_compiled
93.88%8768261699972php-5.4.2-phpbrew_compiled
74.92%10041561756431php-5.4.3-phpbrew_compiled
100.55%8113211627125php-5.4.4-phpbrew_compiled
97.03%8119621599778php-5.4.5-phpbrew_compiled
99.52%8115411619223php-5.4.6-phpbrew_compiled
102.96%8004331624590php-5.4.7-phpbrew_compiled
95.02%8118811583319php-5.4.8-phpbrew_compiled
84.56%9491951751802php-5.4.9-phpbrew_compiled
50%
updown
50%