Created
January 9, 2020 04:11
-
-
Save zhanglianxin/c6c975cac22643419fe70b1ada2070c1 to your computer and use it in GitHub Desktop.
Which is faster between comma and dot when in echo statement?
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 | |
const CC = 1e7; | |
function gg() { | |
static $a = 0; | |
while ($a < CC) { | |
yield $a++; | |
} | |
} | |
function gg1() { | |
static $a = 0; | |
while ($a < CC) { | |
yield $a++; | |
} | |
} | |
$s = time(); | |
foreach (gg() as $i) { | |
echo $i, $i, PHP_EOL; | |
} | |
$e = time(); | |
$s1 = time(); | |
foreach (gg1() as $i) { | |
echo $i . $i . PHP_EOL; | |
} | |
$e1 = time(); | |
echo ($e - $s), PHP_EOL; | |
echo ($e1 - $s1), PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment