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

Parsetime calculation

 
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
Frank
Smarty Rookie


Joined: 18 Apr 2003
Posts: 6

PostPosted: Mon Apr 21, 2003 7:01 pm    Post subject: Parsetime calculation Reply with quote

I don't know if it is usefull but why not:

I was wondering if there could be a function build into smarty that could calculate parsetime such as:

{parsetime start}
blalalalaa html etc more html
Page parsed in {/parsetime end}

And template parsetime as well but that is a bit lazy I think :[img][/img]
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Apr 21, 2003 7:43 pm    Post subject: Reply with quote

The debug console has a lot of parse time functionality built in. Or are you referring to something that would display at the bottom of the web page?
Back to top
View user's profile Send private message Visit poster's website
Frank
Smarty Rookie


Joined: 18 Apr 2003
Posts: 6

PostPosted: Mon Apr 21, 2003 10:28 pm    Post subject: Reply with quote

Yeah something like: Total parsetime: $bla Template parsing done in: $bla1. Would be nice to have it
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Apr 22, 2003 4:48 am    Post subject: Reply with quote

I'm wondering what the best way would be to go about it. It's no problem collecting the parsetime for a call to display(), but the problem is you don't know the parsetime until <i>after</i> the template is parsed, so it's too late to put the parsetime in the template Smile I suppose a post-filter could plug the parsetime in afterwards... but you wouldn't want to have to test for that when it's not used.

Monte
Back to top
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Tue Apr 22, 2003 5:27 am    Post subject: Reply with quote

At first, I was thinking along the lines of mohrt as well--how to report the time before the deed is done? Then I wondered if Frank was really meaning "time the following block of code". That would imply timing a portion of the template and not the entire display() call.

perhaps like:

Code:
{timeblock name=myblock}
blalalalaa html etc more html
{/timeblock}

Block parsed in {$myblock.parsetime}


As to mohrt's question, one way of providing timing values back is to create 'special' smarty constants. When the special constants are not detected in a template use standard one-pass processing with no timing code. When special constants are detected in a template, revert to a two-pass process--the first exactly the same as the prior case, except that timing code is enabled and the special constants ignored. The second pass replaces the constants with the collected timing results from the first pass. Shouldn't be a big deal performance wise as it should only be used during debugging (yes? no?) and only collects timing for the first pass, which is the normal operating case.

Hmmm. My gut says that it is something better left in the API as opposed to being available from templates directly. That may just be because I can't see what use it is to anyone but developers (including template developers) when that info is mostly already provided by the debug console.
Back to top
View user's profile Send private message
mocean
Smarty Rookie


Joined: 21 May 2003
Posts: 30
Location: The Netherlands

PostPosted: Fri May 23, 2003 11:27 am    Post subject: Reply with quote

I'm also interested in this feature. Isn't it possible to do this with one or two custom functions?
Like
Code:

{timer name="timer1" option="start"}
    code here
{timer name="timer1" option="end"}
    more code
{timer name="timer1" option="display"}


In this way they can also be nested easily:
Like
Code:

{timer name="timer1" option="start"}
    code here
    {timer name="timer2" option="start"}
         code here
    {timer name="timer2" option="end"}

{timer name="timer1" option="end"}
    more code
{timer name="timer1" option="display"}
{timer name="timer2" option="display"}


You could also put the values in variables $timer1 and $timer2 after the end is called.

Although, I'm wondering if you really measure a realistic time this way. I am to new to Smarty to oversee that Smile
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri May 23, 2003 2:48 pm    Post subject: Reply with quote

@mocean: if you are running a CVS version of Smarty, you may be interested in this plugin.
Back to top
View user's profile Send private message
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
Page 1 of 1

 
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