Skip to content

Instantly share code, notes, and snippets.

@zhanglianxin
Created January 9, 2020 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhanglianxin/c6c975cac22643419fe70b1ada2070c1 to your computer and use it in GitHub Desktop.
Save zhanglianxin/c6c975cac22643419fe70b1ada2070c1 to your computer and use it in GitHub Desktop.
Which is faster between comma and dot when in echo statement?
<?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