Home Backend Development PHP Tutorial Check the class of php code running time

Check the class of php code running time

Jul 25, 2016 am 09:03 AM

  1. <p><?php
  2. /**
  3. * Function: View the running time of php code
  4. * Date: 2012-12-29
  5. * File: show_php_runtime.php
  6. **/</p>
  7. <p>class RunTime//Page execution time class
  8. {
  9. private $starttime;// Page start execution time
  10. private $stoptime;//Page end execution time
  11. private $spendtime;//Page execution time spent
  12. function getmicrotime()//Get the floating point number that returns the current microseconds
  13. {
  14. list($usec, $sec)=explode(" ",microtime());
  15. return ((float)$usec + (float)$sec);
  16. }
  17. function start()//The page starts executing the function and returns the time when the page execution starts
  18. {
  19. $this->starttime=$this->getmicrotime();
  20. }
  21. function end()//Display the time of page execution
  22. {
  23. $this->stoptime=$this->getmicrotime( );
  24. $this->spendtime=$this->stoptime-$this->starttime;
  25. //return round($this->spendtime,10);
  26. }
  27. function display()
  28. {
  29. //$this->end();
  30. echo "<p>Running time:".round($this->spendtime,10)."Seconds</p>";
  31. }
  32. }< /p>
  33. <p>/*
  34. Call method
  35. */
  36. $timer=new Runtime();
  37. $timer->start();
  38. ?></p>
Copy code


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

11 Best PHP URL Shortener Scripts (Free and Premium) 11 Best PHP URL Shortener Scripts (Free and Premium) Mar 03, 2025 am 10:49 AM

11 Best PHP URL Shortener Scripts (Free and Premium)

Working with Flash Session Data in Laravel Working with Flash Session Data in Laravel Mar 12, 2025 pm 05:08 PM

Working with Flash Session Data in Laravel

Simplified HTTP Response Mocking in Laravel Tests Simplified HTTP Response Mocking in Laravel Tests Mar 12, 2025 pm 05:09 PM

Simplified HTTP Response Mocking in Laravel Tests

Introduction to the Instagram API Introduction to the Instagram API Mar 02, 2025 am 09:32 AM

Introduction to the Instagram API

Build a React App With a Laravel Back End: Part 2, React Build a React App With a Laravel Back End: Part 2, React Mar 04, 2025 am 09:33 AM

Build a React App With a Laravel Back End: Part 2, React

cURL in PHP: How to Use the PHP cURL Extension in REST APIs cURL in PHP: How to Use the PHP cURL Extension in REST APIs Mar 14, 2025 am 11:42 AM

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

12 Best PHP Chat Scripts on CodeCanyon 12 Best PHP Chat Scripts on CodeCanyon Mar 13, 2025 pm 12:08 PM

12 Best PHP Chat Scripts on CodeCanyon

Notifications in Laravel Notifications in Laravel Mar 04, 2025 am 09:22 AM

Notifications in Laravel

See all articles