Categories > TinyButStrong general >

page generation time.

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: shashi
Date: 2011-08-23
Time: 16:38

page generation time.

Hi,

is there a way to output page-geneartion-time when using TBS?

Thanks,
By: Skrol29
Date: 2011-08-23
Time: 20:47

Re: page generation time.

Hi,

You have to set the Render property to TBS_NOTHING, then save the time before the LoadTemplate(), and after the Show().
By: Shashi
Date: 2011-08-24
Time: 11:45

Re: page generation time.

Hi,

An example would be great.


<?php
//start



// end
?>
By: Skrol29
Date: 2011-08-26
Time: 22:36

Re: page generation time.


$TBS = new clsTinyButStrong;

$t0 = f_Misc_Timer();

$TBS->LoadTemplate('my_template.html');
... // lot of business process here
$TBS->Show(TBS_NOTHING);

$t1 = f_Misc_Timer();

$TBS->MergeField('duration', ($t1 - $t0)); // merge the duration in the template if needed

echo $TBS->Source;
exit;

function f_Misc_Timer() {
  $x = microtime() ;
  $Pos = strpos($x," ") ;
  if ($Pos===False) {
    $x = "0.0" ;
  } else {
    $x = substr($x,$Pos+1).substr($x,1,$Pos) ;
  } ;
  return (float)$x ;
}