Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 06:01 am EDT

Geeklog Forums

Block Timer


Status: offline

squatty

Forum User
Full Member
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?
 Quote

Status: offline

Tony

Site Admin
Admin
Registered: 12/17/01
Posts: 405
Location:Urbandale, Iowa
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.
 Quote

Anonymous

Anonymous
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

Status: offline

squatty

Forum User
Full Member
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?
 Quote

All times are EDT. The time is now 06:01 am.

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