<?php
function hello(float $a, float $b, float $c, float $d){
return $a+$b+$c+$d;
}
function hello2($a, $b, $c, $d){
return $a+$b+$c+$d;
}
function millis(){
return round(microtime(true) * 1000);
}
$a = array(1,2,3,4,"test");
$t = millis();
for($i=0;$i<500000;$i++){
hello($a[0],$a[1],$a[2],$a[3]);
}
echo("with types: " . (millis() -$t) . " ms\n");
$t = millis();
for($i=0;$i<500000;$i++){
hello2($a[0],$a[1],$a[2],$a[3]);
}
echo("without types: " . (millis() -$t) . " ms\n");
preferences:
29.85 ms | 402 KiB | 5 Q