Class for viewing php code runtime
-
/**
- * Function: view the php code running time
- * Date: 2012-12-29
- * File: show_php_runtime.php
- **/
-
Class RunTime // page execution time class
- {
- Private $ starttime; // execution time of the page
- Private $ stoptime; // page end execution time
- Private $ spendtime; // time taken for page execution
- Function getmicrotime () // gets the floating point number of the current microsecond.
- {
- List ($ usec, $ sec) = explode ("", microtime ());
- Return (float) $ usec + (float) $ sec );
- }
- Function start () // start the execution of the function on the page, and return the execution time of the start page.
- {
- $ This-> starttime = $ this-> getmicrotime ();
- }
- Function end () // display the page execution time
- {
- $ This-> stoptime = $ this-> getmicrotime ();
- $ This-> spendtime = $ this-> stoptime-$ this-> starttime;
- // Return round ($ this-> spendtime, 10 );
- }
- Function display ()
- {
- // $ This-> end ();
- Echo"
Run time: ". round ($ this-> spendtime, 10)." seconds ";
- }
- }
-
/*
- Call method
- */
- $ Timer = new Runtime ();
- $ Timer-> start ();
- ?>
|