2017 © Pedro Peláez
 

library benchkit

Benchmark helper inspired from Golang

image

fruit/benchkit

Benchmark helper inspired from Golang

  • Thursday, December 1, 2016
  • by Ronmi
  • Repository
  • 1 Watchers
  • 2 Stars
  • 199 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

BenchKit

This package is part of Fruit Framework., (*1)

BenchKit is set of tools helping you benchmark your program., (*2)

Build Status, (*3)

Synopsis

See mybench.php in example folder., (*4)

How to write benchmarks

A benchmark test must be function or public method. It must receive only one parameter with type-hinting., (*5)

Organize your benchmarks

Benchmarks are grouped by their class. So it's suggested to put different group of benchmarks into different files., (*6)

Benchmark function are collected into an unnamed group., (*7)

Command line helper

bench is command line benchmark runner. It will scan specified directory recursivly, find out all benchmark functions, and run. For example:, (*8)

bench run example

Thanks to CLIFramework, you can run bench help run to see supported command line arguments., (*9)

bench does not support construct arguments, you have to write your own benchmark executor to register benchmarks and run it., (*10)

XHProf

You can gather xhprof data when running benchmarks with default command line runner by, (*11)

  • enable --xhprof option and
  • use Fruit\BenchKit\Formatter\XhprofSummary summary formatter.

Passing constructor arguments to formatter

You can pass a string as constructor argument to formatter with --sa and --pa options., (*12)

Generate multiple summary without running benchmarks several times

Use Fruit\BenchKit\Formatter\ChainSummary, and pass constructor argument to specify what formatters you want., (*13)

bench run -s 'Fruit\BenchKit\Formatter\ChainSummary' --sa '{"chain":["Fruit\\BenchKit\\Formatter\\HighChartSummary":"{\"type\":\"time\"}", "Fruit\\BenchKit\\Formatter\\XhprofSummary":""]}' -p 'Fruit\BenchKit\Formatter\NullProgressLogger' example > /tmp/chart.html

Beware about shell escaping and php string escaping because builtin formatters accepts argument in JSON format. Use --argdebug when in doubt., (*14)

License

Any version of MIT, GPL or LGPL., (*15)

The Versions