Interpreting the specific code implementation of PHP computing page execution time _ PHP Tutorial

Source: Internet
Author: User
Describe the specific code implementation of PHP computing page execution time. The code for calculating the page execution time using PHP is as follows :? Phpclassruntime {var $ StartTime0; var $ StopTime0; functionget_microtime () {list ($ usec, $ sec) explode (, mi throughThe code for calculating the page execution time in PHP is as follows:

 
 
  1. Php
  2. Class runtime
  3. {
  4. Var $StartTime=0;
  5. Var $StopTime=0;
  6. Function get_microtime ()
  7. {
  8. List ($ usec, $ sec) = explode ('', microtime ());
  9. Return (float) $ usec + (float) $ sec );
  10. }
  11. Function start ()
  12. {
  13. $ This->StartTime= $ This->Get_microtime ();
  14. }
  15. Function stop ()
  16. {
  17. $ This->StopTime= $ This->Get_microtime ();
  18. }
  19. Function spent ()
  20. {
  21. Return round ($ this->StopTime-$ this->StartTime) * 1000, 1 );
  22. }
  23. }
  24. // Example
  25. $Runtime=NewRuntime;
  26. $ Runtime->Start ();
  27. // Start your code
  28. $A=0;
  29. For ($I=0; $ I<1000000; $ I ++)
  30. {
  31. $ A + = $ I;
  32. }
  33. // Your code ends
  34. $ Runtime->Stop ();
  35. Echo "page Execution time:". $ runtime->Spent (). "millisecond ";
  36. ?>

By understanding the code for calculating the page execution time in PHP, new users should perform their own operations to deepen their understanding.


The code used to calculate the page execution time in PHP is as follows :? Php classruntime {var $ StartTime = 0; var $ StopTime = 0; functionget_microtime () {list ($ usec, $ sec) = explode ('', mi...

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.