Skip to content

Instantly share code, notes, and snippets.

@tobiassjosten
Created August 5, 2010 18:54
Show Gist options
  • Save tobiassjosten/510192 to your computer and use it in GitHub Desktop.
Save tobiassjosten/510192 to your computer and use it in GitHub Desktop.
<?php
function a(array $a) {}
for ($i = 1; $i < 1000000; $i++) @a('');
<?php
function a($a)
{
if (is_array($a)) {}
}
for ($i = 1; $i < 1000000; $i++) a('');
<?php
function a(array $a) {}
for ($i = 1; $i < 1000000; $i++) a(array());
<?php
function a($a)
{
if (is_array($a)) {}
}
for ($i = 1; $i < 1000000; $i++) a(array());
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
@tobiassjosten
Copy link
Author

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