Re: [SMARTY] Re: Template execution time
| From: | messju mohr | Date: | Mon, 12 May 2003 16:48:23 +0000 |
| Subject: | Re: [SMARTY] Re: Template execution time | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-9527@lists.php.net to get a copy of this message | ||
use an insert function to *display* the dynamic part, see:
http://smarty.php.net/manual/en/plugins.inserts.php
use php instead of smarty to *measure* your time. don't use
plugin-functions or the like, they are won't called when the template is
cached.
but a logical problem i see, is that you want to print the time it
took to generate the page into the page. but as i understand it, you
can not know the time in will take in advance. maybe it's best for
you, to do sth. like:
/* have a uniq string like "##time_here##" in the template and replace by hand */
start_time();
$page = $smarty->fetch('tpl'); /* instead of display() */
$milliseconds=end_time();
echo str_replace('##time_here##', $milliseconds, $page);
or:
/* don't cache the foooter that contains the timing-info */
start_time();
$smarty->display('tpl');
$smarty->assign('milliseconds', end_time());
$smarty->caching = false;
$smarty->display('footer.tpl');
HTH
messju
On Mon, May 12, 2003 at 04:50:47PM +0100, pt2002 wrote:
> Hi,
>
> thanks for your answers but my problem isn't really measure the time. I have
> a "timer" class to do that.
> The problem is how to force Smarty always measure script execution even if
> the template is cached.
>
> An example: the first time template is shown, it takes 1 second.
> Second time, template is cached, it takes 0,5 seconds but, because it is
> cached it still show 1 second and I want to show the real time it takes to
> be generated.
> I don't know if explain correctly but my english is poor.
>
> TIA
>
>
>
> "Pt2002" <pt2002@mail.pt> escreveu na mensagem
> news:20030512140314.96254.qmail@pb1.pair.com...
> > Hi
> >
> > I need to show at the end of the page something like "This page took n
> > seconds to be generated" even if the template is cached.
> >
> > I can do:
> >
> > $ini = time();
> >
> > $tpl = new Smarty();
> >
> > if (!is_cached("test.tpl") {
> > $tpl->assign("var1", "xpto")
> > ...
> > }
> >
> > $tpl->display("test.tpl");
> >
> > How can I show the execution time at end of the page?
> > TIA
> >
> >
>
>
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php