Created
August 5, 2010 18:54
-
-
Save tobiassjosten/510192 to your computer and use it in GitHub Desktop.
This file contains 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 a(array $a) {} | |
for ($i = 1; $i < 1000000; $i++) @a(''); |
This file contains 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 a($a) | |
{ | |
if (is_array($a)) {} | |
} | |
for ($i = 1; $i < 1000000; $i++) a(''); |
This file contains 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 a(array $a) {} | |
for ($i = 1; $i < 1000000; $i++) a(array()); |
This file contains 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 a($a) | |
{ | |
if (is_array($a)) {} | |
} | |
for ($i = 1; $i < 1000000; $i++) a(array()); |
This file contains 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
tobias@laptop:~$ time php benchmark1a.php | |
real 0m6.895s | |
user 0m4.480s | |
sys 0m1.280s | |
tobias@laptop:~$ time php benchmark1b.php | |
real 0m5.837s | |
user 0m3.316s | |
sys 0m2.444s | |
tobias@laptop:~$ time php benchmark2a.php | |
real 0m3.447s | |
user 0m2.044s | |
sys 0m1.144s | |
tobias@laptop:~$ time php benchmark2b.php | |
real 0m5.882s | |
user 0m3.220s | |
sys 0m2.648s |
I tried without the @ error suppression too. That put a serious dent in the performance. Without it you're definitely right on signature checking being faster.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hm. So I did a bit more testing:
with an empty arary instead of 'a':
$ time php 1.php # array
real 0m1.531s
$ time php 1.php # is_array
real 0m1.059s
However, with array('foo')
$ time php 1.php #array
real 0m0.932s
$ time php 1.php #is_array
real 0m1.205s