2017 © Pedro Peláez
 

library benchmark

Benchmark with reliable results

image

nochso/benchmark

Benchmark with reliable results

  • Monday, April 18, 2016
  • by nochso
  • Repository
  • 1 Watchers
  • 0 Stars
  • 114 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

nochso/benchmark library

Latest Stable Version License, (*1)

nochso/benchmark creates pretty HTML benchmarks from any closures you supply:, (*2)

  • Generate HTML reports including Github flavoured Markdown
  • Reliably compare different algorithms
  • Run tests for a minimum amount of time to ensure stable results

View an example report, (*3)

View the API documentation, (*4)

Installation

  1. Install composer on Linux / Unix / OSX or Windows
  2. Require this package via composer:, (*5)

    composer require nochso/benchmark
    

Usage

Have a look at the example reports., (*6)

A very simple example without parameters:, (*7)

$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., (*8)

Options

The Report constructor takes an optional third argument $config:, (*9)

public function __construct($title, $description = '', $config = array())

If omitted, default options will be used. Otherwise your configuration will be merged with the defaults., (*10)

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):, (*11)

\nochso\Benchmark\Timer::$defaultMinDuration = 1000;

Contributing

  1. Open an issue if it's worth discussing.
  2. Fork this project on Github.
  3. Clone your fork: git clone git@github.com:yourname/benchmark.git
  4. Don't forget to composer update
  5. Create your feature branch: git checkout -b my-new-feature
  6. Commit your changes: git commit -am 'Add some feature'
  7. Push to the branch: git push origin my-new-feature
  8. Submit a pull request on Github :)

Change log

See CHANGELOG., (*12)

Credits

License

This project is licensed under the ISC license which is MIT/GPL compatible and FSF/OSI approved:, (*13)

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.

The Versions