Created
December 10, 2018 20:36
-
-
Save natanfelles/15b1d253cb285cc8f53a262983ffdf93 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 | |
// https://3v4l.org/gDRdq | |
$foo = 'a/b/c/d/e'; | |
$bar = null; | |
$m = memory_get_usage(); | |
$t = microtime(true); | |
for($i = 0; $i < 10000; $i++) | |
{ | |
$bar = strtr($foo, '/', '-'); | |
} | |
var_dump( | |
memory_get_usage() - $m, | |
microtime(true) - $t | |
); | |
echo $bar. "\n"; | |
$bar = null; | |
$m = memory_get_usage(); | |
$t = microtime(true); | |
for($i = 0; $i < 10000; $i++) | |
{ | |
$bar = str_replace('/', '-', $foo); | |
} | |
var_dump( | |
memory_get_usage() - $m, | |
microtime(true) - $t | |
); | |
echo $bar. "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment