Pear Benchmarking Test PHP program efficiency

Source: Internet
Author: User
Tags benchmark pear

Used to be microtime () to tinker with, do not use, the display results are not clear enough.
Remember Pear has a benchmarking class can be done, has notTimeTry, and finally just tried, very easy to use, hehe
Install Benchmarking First
Pear Install benchmarking# the command line installation benchmarking
There are 3 PHP in benchmarkingfile, respectively:
Benchmark_timer the most basic class in this package. Perform a simplefunctionTo record the total time and the setCodeFragment time.
Benchmark_profiler is like the Benchmark_timer allows you to specify any node between the start and the end. He also provides a way to indicate the number and time of a function's execution through an inline timer.
Benchmark_iterate This is kind of likeMySQLInside the benchmark () function. Executes n times on a piece of code (typically a function), recording each and every execution time.
Example of the previous Benchmark_timer
<?php
Require_once "benchmark/timer.php";
$timer = new Benchmark_timer (TRUE);//contains class files,instanceof class
$timer->start ()/Start timing
Echo Php_sapi_name ();
$timer->setmarker (' Midway ');//Set breakpoints and names
Echo Php_uname ();
EchoPHP_os;
$timer->stop ()//Stop timing
$timer->display ()//Display results
?>
The results are similar to the following display
----------------------------------------------------
Marker Time Index ex-time PERCT
----------------------------------------------------
Start 1182558324.48638900-0.00%
----------------------------------------------------
Midway 1182558324.48655800 0.000169 62.13%
----------------------------------------------------
Stop 1182558324.48666100 0.000103 37.87%
----------------------------------------------------
total-0.000272 100%
----------------------------------------------------the rest of the talk, I read the manual

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.