Two methods for calculating the page execution time

Source: Internet
Author: User

Use PHP to calculate the page execution time. For example, many query pages require statistics on the page execution time,

For example, how many seconds Does Baidu Google query? Currently, a PHP-written computing method is provided.

/*** Get current time */function getmicrotime () {list ($ USEC, $ Sec) = explode ("", microtime (); Return (float) $ USEC + (float) $ Sec );}

Set $ timestart = getmicrotime ();

End Time of program execution: $ timeend = getmicrotime ();

The two time difference is the page execution time.

The following code is written using Js.

We can see from other sites that it is good to use js to calculate the page execution time,

<Script language = JavaScript> <! -- Var starttime, endtime; var d = new date (); starttime = D. gettime (); // --> </SCRIPT> <script language = JavaScript> d = new date (); endtime = D. gettime (); document. write (endtime-starttime)/1000); </SCRIPT>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.