Ec (2); create an object $ timernewBenchmark_Timer (); timing start $ timer-& gt; start (); a script for testing ($ i0; $ I & lt; 1000; $ I ++) {wedonothinghere} set the tag $ timer-& gt; setMarker (& quot; Mark1 & quot;); script ec (2); script
// Create an object
$ Timer = new Benchmark_Timer ();
// Start timing
$ Timer-> start ();
// Test a script
For ($ I = 0; I I <1000; $ I ++)
{
// We do nothing here
}
// Set the tag
$ Timer-> setMarker ("Mark1 ");
// When two points are output
Echo $ timer-> timeElapsed ("Start", "Mark1 ");
?>
Then, we can get the result 0.000543, which is roughly the time consumed from the start point to the Mark1 point.
Class Method
Method: Benchmark_Timer ([mixed $ auto = false])
Description: constructor, which starts the timer record.
Parameter: boolean $ auto. The default value is false. If it is set to true, the timer result is automatically printed.
Time index ex time %
Start 1099020859.80505200-0.00%
Stop 1099020859.80595000 0.000898 100.00%
Total-0.000898 100.00%
The START/End Time indexes are listed separately, and the running time between the last tag as a percentage of the total time consumed (so the Stop point is always 100% ), and total time consumption.
Method: display ()
Description: prints the information returned by the getOutput method.
See the following table:
Time index ex time %
Start 1099021292.32145600-0.00%
Mark1 1099021292.32202000 0.000564 46.38%
Mark2 1099021292.32209700 0.000077 6.33%
Stop 1099021292.32267200 0.000575 47.29%
Total-0.001216 100.00%
Lists the Time Indexes of each tag, the running time between the last tag, the percentage of running time between the last tag and the total time consumption.
Before calling this method, call stop () to terminate the timer (and the program will not be terminated). See example 2. Method: getOutput ()
Description: returns the formatted timer information. This method places the timer information in a table (such as the table above) for the display () method.
Method: getProfiling ()
Description: returns the timer information, as shown in the following figure.
Array
(
[0] => Array
(
[Name] => Start
[Time] = & gt; 1099021787.69669100
[Diff] =>-
[Total] = & gt; 1099021787.696691
)
[1] => Array
(
[Name] => Mark1
[Time] = & gt; 1099021787.69675900
[Diff] = & gt; 0.000068
[Total] = & gt; 1099021787.696759
)
[2] => Array
(
[Name] => Mark2
[Time]