addmarker("Start"); } // end function start() // Call this function at the end of the script function stop() { // Please see the addmarker function later $this->addmarker("Stop" ); } // end function stop() // This function is used to add a marker when the script is executed // It needs a name to describe function addmarker($name) { // Call the jointime() function and add microtime( ) is passed to $markertime = $this->jointime(microtime()); // $ae gets the size of the current array, which is the current insertion position // currently in the $points array $ae = count($ this->points); // Store timestamp and description in array $this->points[$ae][0] = $markertime; $this->points[$ae][1] = $name; } // end function addmarker() // This function will process the string returned from microtime() function jointime($mtime) { // Decompose the string $timeparts = explode(" ",$mtime); // Join two strings , and remove the 0 in the decimal part $finaltime = $timeparts[1].substr($timeparts[0],1); // Return the connected string return $finaltime; } // end function jointime() // This The function simply displays the time required from start to end function showtime() { echo bcsub($this->points[count($this->points)-1][0],$this->points[0][ 0],6); } // end function showtime() // This function displays all the information collected during the execution of the script function debug() { echo "Script execution debug information:"; echo " "; // This table has 3 columns Marker name, Timestamp, difference echo "MarkerTimeDiff "; // The first line is echo without running time difference " "; echo "".$this->points[0][1].""; echo "".$this->points[0][0].""; echo "- "; echo " "; // Loop display starting from element 1 of the array, 0 has been displayed in the first line for ($i = 1; $i points);$i++) { echo " "; echo "".$this->points[$i][1].""; echo "".$this->points[$i][0].""; echo ""; // Display up and down The time difference between the two lines echo bcsub($this->points[$i][0],$this->points[$i-1][0],6); echo ""; echo " "; } echo ""; } // end function debug() } // end class PHP_timer ?>