jbzoo / profiler
Simple Profiler for PHP code and unit tests
Installs: 16 417
Dependents: 3
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >=5.3
- jbzoo/utils: *
Requires (Dev)
- jbzoo/phpunit: ^1.3
This package is auto-updated.
Last update: 2020-06-08 22:38:17 UTC
README
Simple Profiler for PHP code and unit tests
Usage
use JBZoo\Profiler\Benchmark; // Compare performance of functions Benchmark::compare([ 'md5' => function () { $string = str_repeat(mt_rand(0, 9), 1024 * 1024); return md5($string); }, 'sha1' => function () { $string = str_repeat(mt_rand(0, 9), 1024 * 1024); return sha1($string); }, 'crc32' => function () { $string = str_repeat(mt_rand(0, 9), 1024 * 1024); return crc32($string); }, ], array('count' => 500, 'name' => 'Hash functions')); /* Result: ---------- Start benchmark: Hash functions ---------- Running tests 500 times PHP Overhead: time=58 ms; memory=0 B; Testing 1/3 : md5 ... Done! Testing 2/3 : sha1 ... Done! Testing 3/3 : crc32 ... Done! Name of test Time, ms Time, % Memory Memory, % crc32 1 551 ~ 1.25 MB ~ md5 1 938 25 1.25 MB ~ sha1 2 776 79 1.25 MB ~ TOTAL TIME: 6 547.37 ms/4.36 ms; MEMO: 41.05 KB/0.03 KB; COUNT: 1 500 ---------- Finish benchmark: Hash functions ---------- */ Benchmark::run(function () { $string = str_repeat(mt_rand(0, 9), 1024 * 1024); return md5($string); }, ['count' => 1000]),
Unit tests and check code style
make make test-all
License
MIT