Re: [SMARTY] Template execution time
| From: | Ben | Date: | Mon, 12 May 2003 14:33:39 +0000 |
| Subject: | Re: [SMARTY] Template execution time | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-9521@lists.php.net to get a copy of this message | ||
well, i tried the same, but the problem with time() is, that its not exact
enough
to get the time if its less than 1 second.
but for that i just googled a second (parsetime + php)
and found the following:
At first we make a blank file "parsetime.php".
This file contains the following code:
( orig.: Als erstes legen wir eine neue Datei an: "parsetime.php". Diese
Datei enthält folgende Zeilen: )
<?
class parsedur
{
var $start;
var $stop;
function start()
{
list($usec, $sec) = explode(' ', microtime());
$this->start = (float)$usec + (float)$sec;
}
function stop()
{
list($usec, $sec) = explode(' ', microtime());
$this->stop = (float)$usec + (float)$sec;
return number_format($this->stop - $this->start, 4);
}
}
?>
In the beginning of the file, that should show the parsetime you put:
(orig.: An den Anfang der Datei, auf der die Zeit angezeigt werden soll,
kommt: )
<? require("parsetimer.php");
$parsedur = new parsedur();
$parsedur->start();
?>
At the postion where the time should be shown you write:
(orig.: Dort wo die Zeit angezeigt werden soll kommt dann das: )
<?= $parsedur->stop(); ?>
so I'd modifiy this last line to
$myparsetime = $parsedur->stop();
and than do your assign to the template.
That's all
(orig: So das wahr's schon... ;) )
Ressource: http://www.power-php.net/main.php?show=tut_show&tut_id=php_0005
Hope this can help you.
greetz Ben
>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
>
>
>
>---
>__________________________________________________________
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.478 / Virus Database: 275 - Release Date: 06.05.2003
___________________________________________________________________________
ICQ: 30595778
web: http://www.doubleBnet.de
http://www.disco-lifter.de
(Mitfahrgelegenheit für
Discos und Clubs)
http://gbuch.get-digital.de (Hol Dir
Dein kostenloses
Gästebuch)