Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Total page generation time
Goto page Previous  1, 2
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Feature Requests
View previous topic :: View next topic  
Author Message
Dor
Smarty n00b


Joined: 14 May 2005
Posts: 1
Location: Moscow, Russia

PostPosted: Sat May 14, 2005 3:25 pm    Post subject: Reply with quote

May be I misunderstood smthng but I have one question: what for all this complicated stuff? Smile Debugging console ALREADY have compiling time.
And I already have timestats for SQLs and for my PHP code. All that I really need is SMARTY compile times. But I can't get 'em whithout calling SMARTY console. May be there is some way to get compile times WITHOUT showing a console?

I guess SMARTY should have some inner variable with timestats that can be accessed within template(debug.tpl Wink ). Possibly it is empty when not debugging, but I belive there are should be some workaround Smile

---
sorry, if my "english" is a little strange - I have really little practice in it Wink
_________________
Press RESET twice to login.
Back to top
View user's profile Send private message
JurgenD
Smarty Rookie


Joined: 20 Jul 2005
Posts: 12
Location: Belgium

PostPosted: Wed Jul 20, 2005 5:32 pm    Post subject: Reply with quote

I have another approuch to generate it FAST. Because, If You calculate the parsing time of a generated page, Your function does need to be short and fast, to have sharp results.

It works wirht a STATIC variable, and You need to call it twice. On top and on bottom of the template. You may not cache this function.

Code:

// smarty function: stopwatch
// Descr : This function calculates parse time of Your templates
// in microtime
// Author: DEBO Jurgen E. G.
// Usage : Call this twice on top of Your template, and before </body>
// Ex:
// {stopwatch}
// <html>
// ...
// <p>This page was generated in {stopwatch} seconds</p>
// </body>
// Call : $smarty->register_function('stopwatch', 'stopwatch', false);
// note : Function may NOT be cached
//
function stopwatch($params, &$smarty){
   static $mt_previous = 0;

   //list($usec, $sec) = explode(" ",microtime());
   //$mt_current = (float)$usec + (float)$sec;
   $mt_current = (float) array_sum(explode(' ', microtime()));

   if (!$mt_previous) {
      $mt_previous = $mt_current;
      return "";
   } else {
      $mt_diff = ($mt_current - $mt_previous);
      $mt_previous = $mt_current;
      return sprintf('%.16f',$mt_diff);
   }
}


NOTE: If You do NOT want to bother Your visitors with the parsing info
put it in comment on Your pages in this way:

Code:

<!-- This page was generated in {stopwatch} seconds -->
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Feature Requests All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP