Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: ( FINISHED ) Loading status  (Read 885 times)

Pein

  • Newbie
  • *
  • Karma: 0
  • Posts: 28
  • n0 n33d t0 b3 l33t
( FINISHED ) Loading status
« on: May 28, 2010, 10:03:54 am »

Howdy,

I would ask something, yes I did it right now =), hah. Anyone knows how would I make a script which will show me the loading time of the page.

For example: Page loaded : 0,001ms

Thank for advice!

Pein
« Last Edit: May 28, 2010, 10:07:05 pm by Pein »
Logged

jesth

  • Jr. Member
  • **
  • Karma: 1
  • Posts: 66
Re: Loading status
« Reply #1 on: May 28, 2010, 12:15:00 pm »

A simple googlesearch found this:
Code: [Select]
<?
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
echo '<p>Page generated in '.$total_time.' seconds.</p>'."\n";
?>
Just place it in yoiur index.php where you want it.
Logged

Rui Mendes

  • Development,Testing, Support
  • Hero Member
  • *****
  • Karma: 195
  • Posts: 1009
  • sNews1.7
    • Comunidade Portuguesa
Re: Loading status
« Reply #2 on: May 28, 2010, 04:37:53 pm »

This mod was made some time ago.

Find connect_to_db(); in your snews.php and put after
Quote
timing(True);


Put this on the end of your snews.php
Quote
// Ghassem Tofighi's timing mod
function timing($parameter) {
  switch ($parameter) {
    case True:
      $start_time  = microtime();
      $start_time  = explode(" ", $start_time);
      $start_time  = $start_time[1] + $start_time[0];
      $_SESSION['start_time'] = $start_time;
      break;
      
    case False:
      $end_time    = microtime();
      $end_time    = explode(" ",$end_time);
      $end_time    = $end_time[1] + $end_time[0];
      $start_time  = $_SESSION['start_time'];
      $total_time  = $end_time - $start_time;
      $total_time  = round($total_time,3);
      echo 'This page was created in ' . $total_time.' seconds';
      break;
  }
}

In your index.php, on the footer section call
Quote
<?php timing(False); ?>
Logged
Need a Job on Europe. Linkdin - Facebook / Group

Pein

  • Newbie
  • *
  • Karma: 0
  • Posts: 28
  • n0 n33d t0 b3 l33t
Re: Loading status
« Reply #3 on: May 28, 2010, 10:06:49 pm »

Waaa thank mate! Great mod! Iyaaa thanks once again!
Logged