camspiers / bench
Installs: 29
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/camspiers/bench
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: ~3.7
This package is auto-updated.
Last update: 2025-10-19 17:30:37 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; }