Benchmark_Iterate – About Benchmark_Iterate

About Benchmark_Iterate

This class is useful when you want to iterate over a single piece of code (a function) several times over. Timing information is recorded for every iteration. An example follows.

Benchmark_Iterate in manual mode


require_once 'Benchmark/Iterate.php';

$benchmark = new Benchmark_Iterate;

calculation($num) {
$x sin($num) * 100;
$y tan($x);

$result $benchmark->get();


The example above will generate an output as shown below when run with the PHP CLI SAPI.

Results of a test run of Benchmark_Iterate

    [1] => 0.000073
    [2] => 0.000014
    [3] => 0.000011
    [4] => 0.000011
    [5] => 0.000011
	..93 more results..
	[99] => 0.000011
    [100] => 0.000011
    [mean] => 0.000011
    [iterations] => 100

You can display formatted results either by running the script in automatic mode or by using the display() method. For more information of the methods this class implements, refer to the API documentation.

About Benchmark_Profiler (Previous) Caching (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.