nochso / benchmark
Benchmark with reliable results
Requires
- cebe/markdown: ^1.1
- cocur/slugify: ^2.1.1
- doctrine/collections: ^1.3
- jralph/twig-markdown: ^1.0
- nochso/html-compress-twig: ^1.0
- nochso/omni: ^0.3.8
- symfony/finder: ^3.0
- twig/twig: ^1.21
Requires (Dev)
- codegyre/robo: *
- fabpot/php-cs-fixer: ^1.10
- nochso/sami-theme: ^0.2.0
- phpunit/phpunit: ^5.3
This package is not auto-updated.
Last update: 2024-11-05 04:04:17 UTC
README
nochso/benchmark creates pretty HTML benchmarks from any closures you supply:
- Generate HTML reports including Github flavoured Markdown
- Reliably compare different algorithms
- Run tests for a minimum amount of time to ensure stable results
Installation
-
Install composer on Linux / Unix / OSX or Windows
-
Require this package via composer:
composer require nochso/benchmark
Usage
Have a look at the example reports.
A very simple example without parameters:
$report = new Report('My report name'); $unit = new Unit('Encryption speed'); $unit->addClosure(function ($n) { while ($n--) { $x = str_rot13('secret'); } }, 'rot13'); $unit->addClosure(function ($n) { while ($n--) { $x = str_rot13(str_rot13('secret')); } }, 'rot26'); $report->unitList->add($unit); $report->run();
This will generate and save a HTML report to folder build
by default.
Options
The Report constructor takes an optional third argument $config
:
public function __construct($title, $description = '', $config = array())
If omitted, default options will be used. Otherwise your configuration will be merged with the defaults.
array( 'template_dir' => 'template', 'output_dir' => 'build', 'twig' => array( 'cache' => 'cache/twig', 'auto_reload' => true, 'strict_variables' => true, ), )
You can also change the minimum duration of tests which defaults to 1000 millseconds (1 second):
\nochso\Benchmark\Timer::$defaultMinDuration = 1000;
Contributing
- Open an issue if it's worth discussing.
- Fork this project on Github.
- Clone your fork:
git clone git@github.com:yourname/benchmark.git
- Don't forget to
composer update
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request on Github :)
Change log
See CHANGELOG.
Credits
License
This project is licensed under the ISC license which is MIT/GPL compatible and FSF/OSI approved:
Copyright (c) 2015, Marcel Voigt <mv@noch.so>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.