Using pear::benchmarking timer to implement the PHP program timing

Source: Internet
Author: User
Tags diff pear



Create an Object
$timer = new Benchmark_timer ();

Start the timer.
$timer->start ();

A piece of script for testing
For ($i =0 $i <1000; $i + +)
{
We don't have any here
}

Set markup
$timer->setmarker ("Mark1");

To output between two points
echo $timer->timeelapsed ("Start", "Mark1");
?>
Then, you can get 0.000543 of these results, roughly the time between the start and the Mark1 point.
Class method
Method: Benchmark_timer ([Mixed $auto = false])
Description: Constructor, start timer record.
Parameters: Boolean $auto, the default is False, and if set to True, the timer results are automatically printed. form the table below
Time index ex time%
Start 1099020859.80505200-0.00%
Stop 1099020859.80595000 0.000898 100%
total-0.000898 100%

Lists the start/End time index, the elapsed time between the previous tag and the previous one, the total elapsed time (so the stop point is 100%), and the total duration.
Method: Display ()
Description: Prints the information returned by the GetOutput method.
form 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%

Lists the time index for each tag, the elapsed time between the previous tag and the previous tag, and the total time elapsed, as well as the duration.
Before calling this method, you should call Stop () to terminate the timer (and not terminate the program). See Example 2. Method: GetOutput ()
Description: Returns the formatted timer information. This method puts the timer information in a table (as shown above) for display () method listing.
Method: Getprofiling ()
Description: Returns the timer information. will be shaped like
Array
(
[0] => Array
(
[Name] => Start
[Time] => 1099021787.69669100
[diff] =>-
[Total] => 1099021787.696691
)

[1] => Array
(
[Name] => MARK1
[Time] => 1099021787.69675900
[diff] => 0.000068
[Total] => 1099021787.696759
)

[2] => Array
(
[Name] => MARK2
[TIME]

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.