Skip to content

Instantly share code, notes, and snippets.

@jeremyquinton
Created July 29, 2015 10:18
Show Gist options
  • Save jeremyquinton/5e231c0081b088a9abee to your computer and use it in GitHub Desktop.
Save jeremyquinton/5e231c0081b088a9abee to your computer and use it in GitHub Desktop.
<?php
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$time_start = microtime_float();
$string = "testing string 123";
$number = 2000;
$text = "fdddddd dewwwwww";
for($i = 0; $i <= 100000; $i++) {
$string .= " adding some text " . $number . $text;
}
$time_end = microtime_float();
$time = $time_end - $time_start;
echo "echo double quotes took $time\n";
$time_start = microtime_float();
$string = "testing string 123";
$number = 2000;
$text = 'fdddddd dewwwwww';
for($i = 0; $i <= 100000; $i++) {
$string .= ' adding some text ' . $number . $text;
}
$time_end = microtime_float();
$time = $time_end - $time_start;
echo "echo single quotes took $time\n";
@jeremyquinton
Copy link
Author

Jeremys-MacBook-Pro:opg-core-docker jeremyquinton$ php example.php 
echo double quotes took 0.018709182739258
echo single quotes took 0.023837804794312

Jeremys-MacBook-Pro:opg-core-docker jeremyquinton$ php example.php 
echo double quotes took 0.019231081008911
echo single quotes took 0.019197940826416

Jeremys-MacBook-Pro:opg-core-docker jeremyquinton$ php example.php 
echo double quotes took 0.019853115081787
echo single quotes took 0.019999980926514

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment