Benchmark One - High

2.92896857 - 10000 cycles

Benchmark Two - High

2.66182349 - 10000 cycles

Benchmark One - Low

3.2983084600001 - 10000 cycles

Benchmark Two - Low

3.18192828 - 10000 cycles

Current Benchmark

<?php 

$template 
'
<html><head><title>{$title}</title></head><body><?php if(true) { ?>TRUE!<?php } else { ?>FALSE!<?php } ?></body></html>
'
;
$array = array (
    
'<?php' => '";',
    
'?>' => 'echo "',
);
$title 'Page Title';
eval(
'echo "'.strtr($template$array).'";');

 
?>
vs.
<?php 

$template 
'
<html><head><title>{$title}</title></head><body><?php if(true) { ?>TRUE!<?php } else { ?>FALSE!<?php } ?></body></html>
'
;
$array = array (
    
'<?php' => '";',
    
'?>' => 'echo "',
);
$title 'Page Title';
foreach (
$array as $f => $re)
    
$template str_replace($f$re$template);
eval(
'echo "'.$template.'";');

 
?>

Conclusion

NOTE: Despite low-load results which point to the same loading time (because of the margin of error), the high-load results are pretty conclusive.

After an average of 10000 cycles, the fastest option is Benchmark 2!

<?php 

$template 
'
<html><head><title>{$title}</title></head><body><?php if(true) { ?>TRUE!<?php } else { ?>FALSE!<?php } ?></body></html>
'
;
$array = array (
    
'<?php' => '";',
    
'?>' => 'echo "',
);
$title 'Page Title';
foreach (
$array as $f => $re)
    
$template str_replace($f$re$template);
eval(
'echo "'.$template.'";');

 
?>


Copyright Syridium DV