Skip to content

Instantly share code, notes, and snippets.

@rhenium
Created September 14, 2013 19:06
Show Gist options
  • Save rhenium/6564669 to your computer and use it in GitHub Desktop.
Save rhenium/6564669 to your computer and use it in GitHub Desktop.
<?php
$st = microtime(true);
for($i = 0; $i < 100000000; $i++)
echo 'testabcdeftestabcdeftestabcdeftestabcdeftestabcdeftest';
$sm = microtime(true);
fwrite(STDERR, "single quote" . "\t" . ($sm - $st) . "\n");
$st = microtime(true);
for($i = 0; $i < 100000000; $i++)
echo "testabcdeftestabcdeftestabcdeftestabcdeftestabcdeftest";
$sm = microtime(true);
fwrite(STDERR, "double quote" . "\t" . ($sm - $st) . "\n");
$test = "abcdef";
$st = microtime(true);
for($i = 0; $i < 10000000; $i++)
echo 'test' . $test . 'test' . $test . 'test' . $test . 'test' . $test . 'test' . $test . 'test';
$sm = microtime(true);
fwrite(STDERR, "single quote, dot" . "\t" . ($sm - $st) . "\n");
$st = microtime(true);
for($i = 0; $i < 10000000; $i++)
echo "test" . $test . "test" . $test . "test" . $test . "test" . $test . "test" . $test . "test";
$sm = microtime(true);
fwrite(STDERR, "double quote, dot" . "\t" . ($sm - $st) . "\n");
$st = microtime(true);
for($i = 0; $i < 10000000; $i++)
echo "test", $test, "test", $test, "test", $test, "test", $test, "test", $test, "test";
$sm = microtime(true);
fwrite(STDERR, "double quote, comma" . "\t" . ($sm - $st) . "\n");
$st = microtime(true);
for($i = 0; $i < 10000000; $i++)
echo "test${test}test${test}test${test}test${test}test${test}test";
$sm = microtime(true);
fwrite(STDERR, "double quote, \${i}" . "\t" . ($sm - $st) . "\n");
$st = microtime(true);
for($i = 0; $i < 10000000; $i++)
echo "test{$test}test{$test}test{$test}test{$test}test{$test}test";
$sm = microtime(true);
fwrite(STDERR, "double quote, {\$i}" . "\t" . ($sm - $st) . "\n");
$st = microtime(true);
for($i = 0; $i < 10000000; $i++)
echo "test$test test$test test$test test$test test$test test";
$sm = microtime(true);
fwrite(STDERR, "double quote, \$i" . "\t" . ($sm - $st) . "\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment