Created
June 27, 2017 13:49
-
-
Save goosehub/bb64499ede14004d9e3dbb256cb03227 to your computer and use it in GitHub Desktop.
strtolower() vs strtoupper performance test
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 | |
$string = 'hello world'; | |
$start_time = microtime(); | |
for ($i = 0; $i < $max = 10000000; $i++) { | |
strtolower($string); | |
} | |
$timed = microtime() - $start_time; | |
echo 'strtolower ' . $string . ' - ' . $timed . '<br>'; | |
$string = 'hello world'; | |
$start_time = microtime(); | |
for ($i = 0; $i < $max = 10000000; $i++) { | |
strtoupper($string); | |
} | |
$timed = microtime() - $start_time; | |
echo 'strtoupper ' . $string . ' - ' . $timed . '<br>'; | |
$string = 'HELLO WORLD'; | |
$start_time = microtime(); | |
for ($i = 0; $i < $max = 10000000; $i++) { | |
strtolower($string); | |
} | |
$timed = microtime() - $start_time; | |
echo 'strtolower ' . $string . ' - ' . $timed . '<br>'; | |
$string = 'HELLO WORLD'; | |
$start_time = microtime(); | |
for ($i = 0; $i < $max = 10000000; $i++) { | |
strtoupper($string); | |
} | |
$timed = microtime() - $start_time; | |
echo 'strtoupper ' . $string . ' - ' . $timed . '<br>'; | |
$string = 'Hello World'; | |
$start_time = microtime(); | |
for ($i = 0; $i < $max = 10000000; $i++) { | |
strtolower($string); | |
} | |
$timed = microtime() - $start_time; | |
echo 'strtolower ' . $string . ' - ' . $timed . '<br>'; | |
$string = 'Hello World'; | |
$start_time = microtime(); | |
for ($i = 0; $i < $max = 10000000; $i++) { | |
strtoupper($string); | |
} | |
$timed = microtime() - $start_time; | |
echo 'strtoupper ' . $string . ' - ' . $timed . '<br>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment