Created
July 31, 2019 19:56
-
-
Save imanghafoori1/a9f672a9cc0a693737a75612822c3b82 to your computer and use it in GitHub Desktop.
compare type hint performance hit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function a1(int $a,int $b) : int { | |
return $a + $b; | |
} | |
function a2( $a, $b){ | |
return $a + $b; | |
} | |
$f = microtime(true); | |
for($a = 0; $a<100000; $a++) { | |
a1(1, 1); | |
} | |
echo microtime(true) - $f; | |
$f = microtime(true); | |
for($a = 0; $a<100000; $a++) { | |
a2(1, 1); | |
} | |
echo ' - without type-hint: '; | |
echo microtime(true) - $f; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment