-
-
Save mkantor/5521360 to your computer and use it in GitHub Desktop.
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
$ uname -a | |
Linux betty 2.6.32-46-generic #108-Ubuntu SMP Thu Apr 11 15:55:01 UTC 2013 i686 GNU/Linux | |
$ php --version | |
PHP 5.3.2-1ubuntu4.19 with Suhosin-Patch (cli) (built: Mar 11 2013 15:23:47) | |
Copyright (c) 1997-2009 The PHP Group | |
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies | |
with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans | |
$ for i in {1..3}; do time php substrstrlen.php; done | |
real 0m24.045s | |
user 0m11.765s | |
sys 0m12.093s | |
real 0m24.106s | |
user 0m12.033s | |
sys 0m11.685s | |
real 0m24.160s | |
user 0m11.569s | |
sys 0m12.045s | |
$ for i in {1..3}; do time php strpos.php; done | |
real 0m11.865s | |
user 0m5.792s | |
sys 0m5.992s | |
real 0m11.865s | |
user 0m5.816s | |
sys 0m5.964s | |
real 0m12.549s | |
user 0m5.948s | |
sys 0m5.924s | |
$ for i in {1..3}; do time php substrstrlen_outside.php; done | |
real 0m12.665s | |
user 0m6.408s | |
sys 0m6.152s | |
real 0m12.642s | |
user 0m6.308s | |
sys 0m6.080s | |
real 0m12.576s | |
user 0m6.348s | |
sys 0m6.096s | |
... | |
# This run was in a VirtualBox VM with a much different configuration than | |
# above, so it's probably best not to directly compare these to eachother. | |
$ uname -a | |
Linux precise32 3.2.0-23-generic-pae #36-Ubuntu SMP Tue Apr 10 22:19:09 UTC 2012 i686 i686 i386 GNU/Linux | |
$ php --version | |
PHP 5.3.10-1ubuntu3.6 with Suhosin-Patch (cli) (built: Mar 11 2013 14:34:31) | |
Copyright (c) 1997-2012 The PHP Group | |
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies | |
$ for i in {1..3}; do time php substrstrlen.php; done | |
real 0m0.738s | |
user 0m0.708s | |
sys 0m0.024s | |
real 0m0.677s | |
user 0m0.636s | |
sys 0m0.036s | |
real 0m0.694s | |
user 0m0.664s | |
sys 0m0.028s | |
$ for i in {1..3}; do time php strpos.php; done | |
real 0m0.310s | |
user 0m0.260s | |
sys 0m0.044s | |
real 0m0.332s | |
user 0m0.296s | |
sys 0m0.032s | |
real 0m0.298s | |
user 0m0.280s | |
sys 0m0.012s | |
$ for i in {1..3}; do time php substrstrlen_outside.php; done | |
real 0m0.428s | |
user 0m0.396s | |
sys 0m0.028s | |
real 0m0.404s | |
user 0m0.376s | |
sys 0m0.024s | |
real 0m0.489s | |
user 0m0.464s | |
sys 0m0.016s | |
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 | |
$class = 'Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration'; | |
$prefix = 'Twig_'; | |
for ($i = 0; $i < 1000000; ++$i) { | |
if (0 === strpos($class, $prefix)) {} | |
} |
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 | |
$class = 'Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration'; | |
$prefix = 'Twig_'; | |
for ($i = 0; $i < 1000000; ++$i) { | |
if (substr($class, 0, strlen($prefix)) === $prefix) {} | |
} |
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 | |
$class = 'Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration'; | |
$prefix = 'Twig_'; | |
$length = strlen($prefix); | |
for ($i = 0; $i < 1000000; ++$i) { | |
if (substr($class, 0, $length) === $prefix) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment