<html>
<head>
  <title>Simple Benchmark</title>
</head>
<body><?php
$runs = 500000;

function microtime_float()
{
   list($usec, $sec) = explode(" ", microtime());
   return ((float)$usec + (float)$sec);
}

$time_start1 = microtime_float();
for($i=0;$i<$runs;$i++)
{
    $name = 'Arthur';
    $example = 'My name is '.$name;
}
$time_end1 = microtime_float();

$time_start = microtime_float();
for($i=0;$i<$runs;$i++)
{
    $name = "Arthur";
    $example = "My name is $name";
}
$time_end = microtime_float();

$time_start2 = microtime_float();
for($i=0;$i<$runs;$i++)
{
  $name = "Arthur";
  $example = sprintf("My name is %s", $name);
}
$time_end2 = microtime_float();

$time = $time_end - $time_start;
$time1 = $time_end1 - $time_start1;
$time2 = $time_end2 - $time_start2;

echo "Test 1 (single quotes) took $time1 seconds<br>";
echo "Test 2 (variable replacement) took $time seconds<br>";
echo "Test 3 (sprintf) took $time2 seconds<br>";
?> 
</body>
</html>
