/usr/share/netmrg/lib/phptimer.php is in netmrg 0.20-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | <?php
// begin class PHP_timer
class PHP_timer {
// array to store the information that we collect during the script
// this array will be manipulated by the functions within our object
var $points = array();
// call this function at the beginning of the script
function start() {
// see the addmarker() function later on
$this->addmarker("Start");
}
// end function start()
// call this function at the end of the script
function stop() {
// see the addmarker() function later on
$this->addmarker("Stop");
}
// end function stop()
// this function is called to add a marker during the scripts execution
// it requires a descriptive name
function addmarker($name) {
// call the jointime() function and pass it the output of the microtime() function
// as an argument
$markertime = $this->jointime(microtime());
// $ae (stands for Array Elements) will contain the number of elements
// currently in the $points array
$ae = count($this->points);
// store the timestamp and the descriptive name in the array
$this->points[$ae][0] = $markertime;
$this->points[$ae][1] = $name;
}
// end function addmarker()
// this function manipulates the string that we get back from the microtime() function
function jointime($mtime) {
// split up the output string from microtime() that has been passed
// to the function
$timeparts = explode(" ",$mtime);
// concatenate the two bits together, dropping the leading 0 from the
// fractional part
$finaltime = $timeparts[1].substr($timeparts[0],1);
// return the concatenated string
return $finaltime;
}
// end function jointime()
// this function simply give the difference in seconds betwen the start of the script and
// the end of the script
function showtime() {
return round( (($this->points[count($this->points)-1][0]) - ($this->points[0][0])), 6);
}
// end function showtime()
// this function displays all of the information that was collected during the
// course of the script
function debug() {
echo "Script execution debug information:";
echo "<table border=0 cellspacing=5 cellpadding=5>\n";
// the format of our table will be 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 row will have no difference since it is the first timestamp
echo "<tr>\n";
echo "<td>".$this->points[0][1]."</td>";
echo "<td>".$this->points[0][0]."</td>";
echo "<td>-</td>\n";
echo "</tr>\n";
// our loop through the $points array must start at 1 rather than 0 because we have
// already written out 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>";
// write out the difference between this row and the previous row
echo round( ($this->points[$i][0] - $this->points[$i-1][0]), 6);
echo "</td>";
echo "</tr>\n";
}
echo '<tr><td colspan="2">Start to Stop</td>'."\n";
echo '<td>'.round( ($this->points[count($this->points)-1][0] - $this->points[0][0]), 6)."</td>\n";
echo "</tr>\n";
echo "</table>";
}
// end function debug()
}
// end class PHP_timer
?>
|