Jump to content
xisto Community
Sign in to follow this  
cragllo

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

Recommended Posts

As my knowledge of PHP increases, I have learned more, in this version, I use a class.
V1: http://forums.xisto.com/topic/4782-page-loading-time-how-long-does-your-page-take-to-load/

<?phpclass 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?>

Share this post


Link to post
Share on other sites

As my knowledge of PHP increases, I have learned more, in this version, I use a class.V1: http://forums.xisto.com/topic/4782-page-loading-time-how-long-does-your-page-take-to-load/

<?phpclass 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

Share this post


Link to post
Share on other sites

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 ;-)

Share this post


Link to post
Share on other sites

If you wnat the number to have less numbers after its decimal place, simple edit this code

function e() {		$this->et = $this->getmicrotime();		echo round(($this->et - $this->st), 6); //Change this number here	}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.