Class for viewing php code runtime

Source: Internet
Author: User
Class for viewing php code runtime

  1. /**

  2. * Function: view the php code running time
  3. * Date: 2012-12-29
  4. * File: show_php_runtime.php
  5. **/

  6. Class RunTime // page execution time class

  7. {
  8. Private $ starttime; // execution time of the page
  9. Private $ stoptime; // page end execution time
  10. Private $ spendtime; // time taken for page execution
  11. Function getmicrotime () // gets the floating point number of the current microsecond.
  12. {
  13. List ($ usec, $ sec) = explode ("", microtime ());
  14. Return (float) $ usec + (float) $ sec );
  15. }
  16. Function start () // start the execution of the function on the page, and return the execution time of the start page.
  17. {
  18. $ This-> starttime = $ this-> getmicrotime ();
  19. }
  20. Function end () // display the page execution time
  21. {
  22. $ This-> stoptime = $ this-> getmicrotime ();
  23. $ This-> spendtime = $ this-> stoptime-$ this-> starttime;
  24. // Return round ($ this-> spendtime, 10 );
  25. }
  26. Function display ()
  27. {
  28. // $ This-> end ();
  29. Echo"

    Run time: ". round ($ this-> spendtime, 10)." seconds

    ";
  30. }
  31. }

  32. /*

  33. Call method
  34. */
  35. $ Timer = new Runtime ();
  36. $ Timer-> start ();
  37. ?>

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.