Jul 24, 2008

Page Loading Time V2 - how long does your page take to load?

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Page Loading Time V2 - how long does your page take to load?

cragllo
As my knowledge of PHP increases, I have learned more, in this version, I use a class.
V1: http://www.trap17.com/forums/page-loading-time-t4782.html

CODE
<?php
class microtimer {
// Starts, Ends and Displays Page Creation Time
    function getmicrotime() {
        list($usec, $sec) = explode(" ", microtime());
        return ((float)$usec + (float)$sec);
    }
    
    function s() {
        $this->st = $this->getmicrotime();
    }
    
    function e() {
        $this->et = $this->getmicrotime();
        echo round(($this->et - $this->st), 6);
    }
}

$tm = new microtimer;

//A class is a collective function set. Stick that in a file that's included or in the file you're running
//then you use it as follows:


$tm->s();

//put all you PHP code and site code in here

$tm->e();

//and it will display the execute time in seconds to 6 decimal places. Generally i get results such as 0.000158
//just stay aware that php is extremely fast so if it's a small piece of code you'll get lots of 0s on the left
?>

 

 

 


Reply

B4ND1T
QUOTE(cragllo @ Jul 5 2006, 03:47 PM) *

As my knowledge of PHP increases, I have learned more, in this version, I use a class.
V1: http://www.trap17.com/forums/page-loading-time-t4782.html

CODE
<?php
class microtimer {
// Starts, Ends and Displays Page Creation Time
    function getmicrotime() {
        list($usec, $sec) = explode(" ", microtime());
        return ((float)$usec + (float)$sec);
    }
    
    function s() {
        $this->st = $this->getmicrotime();
    }
    
    function e() {
        $this->et = $this->getmicrotime();
        echo round(($this->et - $this->st), 6);
    }
}

$tm = new microtimer;

//A class is a collective function set. Stick that in a file that's included or in the file you're running
//then you use it as follows:
$tm->s();

//put all you PHP code and site code in here

$tm->e();

//and it will display the execute time in seconds to 6 decimal places. Generally i get results such as 0.000158
//just stay aware that php is extremely fast so if it's a small piece of code you'll get lots of 0s on the left
?>




tnx man

 

 

 


Reply

wappy
Ah so the original one is not accurate? I put it on my wap site but use explode to get rid of the E. I had a feeling the start needed to be at the top of code and vice versa lol. Ah well it still looks cool untill i use the new code. Im sure on php.net i read a way to shorten strings.. I will look again at some point as for my tiny wap site the number seems very long, i would have maybe just like 1.65824 ;-)

Reply

cragllo
If you wnat the number to have less numbers after its decimal place, simple edit this code
CODE
    function e() {
        $this->et = $this->getmicrotime();
        echo round(($this->et - $this->st), 6); //Change this number here
    }

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : loading v2 load

  1. Help Php: How To Load String From Text File (solved) - Loading string from text file when you click on your link (9)
  2. Page Loading Time - how long does your page take to load? (7)
    All you have to do is add this code to your page where you want the loading time to be shown, the
    bottom is the most common place. CODE <?php $loadbegintime = microtime();
    $loadbeginarray = explode(" ", $loadbegintime); $loadbegintime =
    $loadbeginarray[1] + $loadbeginarray[0]; $loadendtime =
    microtime(); $loadendarray = explode(" ", $loadendtime);
    $loadendtime = $loadendarray[1] + $loadendarray[0];
    $total_script_time ...
  3. Loading Mysql Data Into A Table - (10)
    Hey i have a little problem with my php script. i dont really know how to make it work ^^; I want to
    have this exact table: ' I made mysql table that has one column for id(auto-increment,
    primary key), and then it has row and collumn and text. row means which row in the html table and
    collumn wich collum. (obviously /tongue.gif" style="vertical-align:middle" emoid=":P" border="0"
    alt="tongue.gif" />) here is the mysql table screenshoted from phpMyAdmin: r means row and c
    collumn /tongue.gif" style="vertical-align:middle" emoid=":P" border="0" alt="tongue...
  4. Loading Some Of The Title From The Include Tag - (2)
    Let's say I have the same PHP script on all pages, with the same menus, footer etc, but with
    different content. The PHP page is called "Sitename - ", and the included pages (which is in HTML)
    is called "Thingy". I want it to load both titles, so the title will be "Sitename - Thingy". The
    second page have the same PHP code (with the normal title, "Sitename - "), but is called "Why not?".
    This one have the title "Sitename - Why not?". Hope you understand what I want, and that you can
    help me. /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> ...



Looking for page, loading, time, v2, long, page, load

Searching Video's for page, loading, time, v2, long, page, load
advertisement



Page Loading Time V2 - how long does your page take to load?



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE