camspiers/bench
Maintainers
0.1.0
2014-02-22 01:51 UTC
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: ~3.7
Suggests
None
Provides
None
Conflicts
None
Replaces
None
MIT 93a3a2fcc9f4e5670b71452cd386470bdb0ed941
- Cam Spiers <camspiers.woop@gmail.com>
This package is auto-updated.
Last update: 2026-06-19 18:49:00 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; }
