Anti-Google search statistics script execution time.

Source: Internet
Author: User
Tags array count execution explode return first row
google| Script | statistics | Executive <?php

Class Php_timer Start
Class Php_timer {

Used to collect information during script execution
var $points = array ();

Call this function at the beginning of the script
function Start () {
Take a look at the Addmarker function in the back
$this->addmarker ("Start");
}
End Function Start ()

Call this function at the end of the script
function Stop () {
Take a look at the Addmarker function in the back
$this->addmarker ("Stop");
}
End Function Stop ()

This function is used to add a tag when the script executes
I need a name to describe.
function Addmarker ($name) {
Call the Jointime () function and pass the return value of Microtime () to the past
$markertime = $this->jointime (microtime ());
$ae get the current array size, which is the current insertion position
Currently in the $points array
$ae = count ($this->points);
Storing timestamp and descriptions in arrays
$this->points[$ae][0] = $markertime;
$this->points[$ae][1] = $name;
}
End Function Addmarker ()

This function handles the string returned from the Microtime ()
function Jointime ($mtime) {
Explode string
$timeparts = Explode ("", $mtime);
Connect two strings and remove the decimal part of 0
$finaltime = $timeparts [1].substr ($timeparts [0],1);
Returns the concatenated string
return $finaltime;
}
End Function Jointime ()

This function simply shows the time that is required from start to finish
function Showtime () {
Echo bcsub ($this->points[count ($this->points) -1][0], $this->points[0][0],6);
}
End Function Showtime ()

This function shows all the information that was collected during the execution of the script.
function Debug () {
echo "Script execution debug Information:";
echo "<table border=0 cellspacing=5 cellpadding=5>\n";
This table has 3 columns Marker name, Timestamp, Difference
echo "<tr><td><b>Marker</b></td><td><b>Time</b></td>< Td><b>diff</b></td></tr>\n ";
The first line is not running the time lag
echo "<tr>\n";
echo "<td>" $this->points[0][1]. " </td> ";
echo "<td>" $this->points[0][0]. " </td> ";
echo "<td>-</td>\n";
echo "</tr>\n";
Starting with the element 1 of the array, 0 is already displayed in the first row.
for ($i = 1; $i < count ($this->points); $i + +) {
echo "<tr>\n";
echo "<td>" $this->points[$i][1]. " </td> ";
echo "<td>" $this->points[$i][0]. " </td> ";
echo "<td>";
Shows the time difference between the next two lines
Echo bcsub ($this->points[$i][0], $this->points[$i -1][0],6);
echo "</td>";
echo "</tr>\n";
}
echo "</table>";
}
End Function Debug ()
}
End Class Php_timer

?>


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.