camspiers/bench

0.1.0 2014-02-22 01:51 UTC

This package is auto-updated.

Last update: 2024-11-19 15:06:11 UTC


README

Basic benchmarking

Usage

Using bench\mark

bench\mark('somekey');
$result = calculateSomething();
echo bench\format(bench\collector()), PHP_EOL;

Using bench\invoke

$result = bench\invoke('calculateSomething');
echo bench\format(bench\collector()), PHP_EOL;

Using bench\wrap

$fn = bench\wrap('calculateSomething');
$result = $fn();
echo bench\format(bench\collector()), PHP_EOL;

Using bench\collector

bench\collector will collect up results of bench\invoke and bench\wrap.

When bench\collector is invoked without arguments it will return all results collected.

When there is only one result it will return that else it will return an array.

bench\invoke('calculateSomething');
bench\invoke('calculateSomething');
foreach (bench\formatTimes(bench\collector()) as $time) {
	echo $time, PHP_EOL;
}