Topics

User Functions

Events

There are no upcoming events

What's New

Stories

No new stories

Comments last 2 weeks

No new comments

Trackbacks last 2 weeks

No new trackback comments

Links last 2 weeks

No recent new links

NEW FILES last 14 days

No new files

Welcome to Geeklog Sunday, May 19 2013 @ 05:48 AM EDT


 Forum Index > Extensions > Cool Hacks New Topic Post Reply
 Block Timer
   
squatty
 04/18/02 07:09AM (Read 2088 times)  
+++++
Full Member

Status: offline


Registered: 01/21/02
Posts: 269
I was wondering if anyone has attempted to make a call to the timer class in order to determine the rendering time per each Block?

This would be a nice feature for hunting down performance issues.

I assume I can add the call to $_PAGE_TIMER->startTimer() in the COM_startBlock() and the $_PAGE_TIMER->stopTimer() to the COM_endBlock () functions?

Will that work or is there more to it? I guess I should try it myslef first Wink

In a world without walls and fences, who needs Windows and Gates?
 
Profile Email Website
 Quote
Tony
 04/18/02 07:44AM  
AAAAA
Admin

Status: offline


Registered: 12/17/01
Posts: 405
You will want to instantiate a new timer object, not use the $_PAGE_TIMER one.

-----
The reason people blame things on previous generations is that there's only one other choice.

The reason people blame things on previous generations is that there's only one other choice.
 
Profile Email Website
 Quote
Anonymous: Anonymous
 04/18/02 02:07PM  



I get Block execution times but, the times are not correct? In theory, the total sum of the Block times should roughly equate to the total time of the page (give or take)?

I think my problem is related to where the start time is being executed? Here's what I've done:

1) Add the following lines just before the COM_startBlock() in lib-common.php

$_BLOCK_TIMER = new timerobject();
$_BLOCK_TIMER->startTimer();

2) Added the following in COM_endBlock() in lib-common.php

$block->set_var('blockexecution_time', $_BLOCK_TIMER->stopTimer());

3) Added the following to /layout/Classic/blockfooter.thtml

<p><font size ="-1">This block executed in: <b></b> secs.</font>

Where should the start time (code in #1) be placed?

You can see all of the above in action at www.squatty.com.

Thanks,
Squatty

 
 Quote
squatty
 04/19/02 06:06AM  
+++++
Full Member

Status: offline


Registered: 01/21/02
Posts: 269
I took another approach and am now getting the results I expected. Here's what I did:

1) In lib-custom.php added the following to each of my PHP Blocks that I wanted to be timed:

global $_CONF, $_WEATHER_TIMER;
//TIMER NAME = $WEATHER_TIMER
$_WEATHER_TIMER = new timerobject();
$_WEATHER_TIMER->startTimer();

For example, here's my weather PHP BLOCK:

function phpblock_getweather () {

global $_CONF, $_WEATHER_TIMER;
$_WEATHER_TIMER = new timerobject();
$_WEATHER_TIMER->startTimer();
$path = $_CONF['path_html'] . "weather";
include_once($path . "/display_weather.php"Wink;
$display = getweather();
return $display;
}

2) In the block code (display_weather.php in the case of the weather block) add the following to return the results:

$boxtitle.= "<small><br>Created this block in <b>";
$boxtitle.= $_WEATHER_TIMER->stopTimer();
$boxtitle.= "</b> seconds.</small>";

That's it. You can see the timers at www.squatty.com.

In a world without walls and fences, who needs Windows and Gates?
 
Profile Email Website
 Quote
Content generated in: 0.20 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to post 
Filtered HTML Allowed 
Censored Content