Record page execution time php code-php Tutorial

Source: Internet
Author: User
Record page execution time php code

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


Execution time, php

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.