Benchmark One - High

2.17309659 - 8000 cycles

Benchmark Two - High

2.31494511 - 8000 cycles

Benchmark One - Low

2.57088885 - 8000 cycles

Benchmark Two - Low

2.59492206 - 8000 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><IF (true)>TRUE!<ELSE>FALSE!</IF></body></html>
'
;
$title 'Page Title';
$template preg_replace('~<IF (.*?)(?<!\-)>(.*?)(<ELSE>(.*?))?</IF>~''".(\\1 ? ("\\2") : ("\\4"))."'$template);
eval(
'echo "'.$template.'";');

 
?>

Conclusion

After an average of 8000 cycles, the fastest option is Benchmark 1!

<?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).'";');

 
?>


Copyright Syridium DV