<?php
 
//here is a quick sample and benchmark for a one dymaic block in one file
 
include_once('cls_ft.php');
 
//include_once('cls_ft.php');
 
$start=microtime();
 
//create the class object and set the root path
 
$ft=new FastTemplate('.');
 
//define one template file
 
$ft->define(array('main' => 'a_dynamic.html'));
 
//define the dynaimc block inside the 'main' template
 
$ft->define_dynamic('a_row','main');
 
 
$z=0;
 
//do a 5000 rows loop and assign $i to a tag... 
 
for($i=0;$i<5000;$i++)
 
{
 
    $ft->assign('B',"row:$i");
 
    $ft->parse('AROW_OUT','.a_row');
 
   $z++;
 
}
 
 
$ft->assign('A','5000 row test');
 
//parse the template.
 
$ft->parse('MAIN','main');
 
$end=microtime();
 
echo "Printed $z rows in ".microtime_diff($end,$start);
 
//print and get back here
 
$ft->FastPrint('MAIN');
 
 
 
/**
 
 * @return float
 
 * @param a string
 
 * @param b string
 
 * @desc (From php manual) compute the microtime diff format.
 
 */
 
function microtime_diff($a,$b) {
 
     list($a_micro, $a_int)=explode(' ',$a);
 
     list($b_micro, $b_int)=explode(' ',$b);
 
     if ($a_int>$b_int) {
 
        return ($a_int-$b_int)+($a_micro-$b_micro);
 
     } elseif ($a_int==$b_int) {
 
        if ($a_micro>$b_micro) {
 
           return ($a_int-$b_int)+($a_micro-$b_micro);
 
        } elseif ($a_micro<$b_micro) {
 
           return ($b_int-$a_int)+($b_micro-$a_micro);
 
        } else {
 
           return 0;
 
        }
 
     } else { // $a_int<$b_int
 
        return ($b_int-$a_int)+($b_micro-$a_micro);
 
     }
 
  }
 
 
?>
 
 |