2017 © Pedro Peláez
 

library bench

The Hoa\Bench library.

image

hoa/bench

The Hoa\Bench library.

  • Wednesday, June 27, 2018
  • by Hoa
  • Repository
  • 12 Watchers
  • 49 Stars
  • 10,770 Installations
  • PHP
  • 1 Dependents
  • 1 Suggesters
  • 8 Forks
  • 2 Open issues
  • 16 Versions
  • 10 % Grown

The README.md

Hoa , (*1)


Build status Code coverage Packagist License , (*2)

Hoa is a modular, extensible and structured set of PHP libraries.
Moreover, Hoa aims at being a bridge between industrial and research worlds. , (*3)

Hoa\Bench

Help on IRC Help on Gitter Documentation Board, (*4)

This library allows to analyze performance of algorithms or programs by placing some “marks” in the code. Furthermore, this library provides some DTrace programs., (*5)

Learn more., (*6)

Installation

With Composer, to include this library into your dependencies, you need to require hoa/bench:, (*7)

$ composer require hoa/bench '~3.0'

For more installation procedures, please read the Source page., (*8)

Testing

Before running the test suites, the development dependencies must be installed:, (*9)

$ composer install

Then, to run all the test suites:, (*10)

$ vendor/bin/hoa test:run

For more information, please read the contributor guide., (*11)

Quick usage

We propose a quick overview of two usages: The library itself and one DTrace program., (*12)

Benchmark

All we have to do is to place different marks in the code. A mark can be started, paused, stopped and reset. The class Hoa\Bench\Bench proposes a quick statistic graph that could be helpful:, (*13)

$bench = new Hoa\Bench\Bench();

// Start two marks: “one” and “two”.
$bench->one->start();
$bench->two->start();

usleep(50000);

// Stop the mark “two” and start the mark “three”.
$bench->two->stop();
$bench->three->start();

usleep(25000);

// Stop all marks.
$bench->three->stop();
$bench->one->stop();

// Print statistics.
echo $bench;

/**
 * Will output:
 *     __global__  ||||||||||||||||||||||||||||||||||||||||||||||||||||    77ms, 100.0%
 *     one         ||||||||||||||||||||||||||||||||||||||||||||||||||||    77ms,  99.8%
 *     two         ||||||||||||||||||||||||||||||||||                      51ms,  65.9%
 *     three       ||||||||||||||||||                                      26ms,  33.9%
 */

More operations are available, such as iterating over all marks, deleting a mark, filters marks etc., (*14)

DTrace

An interesting DTrace program is hoa://Library/Bench/Dtrace/Execution.d that shows the call trace, errors and exceptions during an execution. For example, if we consider the Dtrace.php file that contains the following code:, (*15)

<?php

function f() { g(); h(); }
function g() { h();      }
function h() {           }

f();

Then, we can run DTrace like this:, (*16)

$ exed=`hoa protocol:resolve hoa://Library/Bench/Dtrace/Execution.d`
$ sudo $exed -c "php Dtrace.php"
Request start
     2ms ➜ f()        …/Dtrace.php:007
    37ms   ➜ g()      …/Dtrace.php:003
    26ms     ➜ h()    …/Dtrace.php:004
    28ms     ← h()
    37ms   ← g()
    44ms   ➜ h()      …/Dtrace.php:003
    25ms   ← h()
    30ms ← f()
Request end

Another program shows statistics about an execution: Each function that has been called, how many times, how long the execution has taken etc., (*17)

Documentation

The hack book of Hoa\Bench contains detailed information about how to use this library and how it works., (*18)

To generate the documentation locally, execute the following commands:, (*19)

$ composer require --dev hoa/devtools
$ vendor/bin/hoa devtools:documentation --open

More documentation can be found on the project's website: hoa-project.net., (*20)

Getting help

There are mainly two ways to get help:, (*21)

Contribution

Do you want to contribute? Thanks! A detailed contributor guide explains everything you need to know., (*22)

License

Hoa is under the New BSD License (BSD-3-Clause). Please, see LICENSE for details., (*23)

The following projects are using this library:, (*24)

The Versions

27/06 2018

dev-master

9999999-dev https://hoa-project.net/

The Hoa\Bench library.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

library time performance trace analyze bench dtrace

11/01 2017

3.17.01.11

3.17.01.11 https://hoa-project.net/

The Hoa\Bench library.

  Sources   Download

BSD-3-Clause

The Requires

 

library time performance trace analyze bench dtrace

24/10 2016

3.16.10.24

3.16.10.24 https://hoa-project.net/

The Hoa\Bench library.

  Sources   Download

BSD-3-Clause

The Requires

 

library time performance trace analyze bench dtrace

15/03 2016

3.16.03.15

3.16.03.15 http://hoa-project.net/

The Hoa\Bench library.

  Sources   Download

BSD-3-Clause

The Requires

 

library time performance trace analyze bench dtrace

11/01 2016

3.16.01.11

3.16.01.11 http://hoa-project.net/

The Hoa\Bench library.

  Sources   Download

BSD-3-Clause

The Requires

 

library time performance trace analyze bench dtrace

21/10 2015

2.15.10.21

2.15.10.21 http://hoa-project.net/

The Hoa\Bench library.

  Sources   Download

BSD-3-Clause

The Requires

 

library time performance trace analyze bench dtrace

13/08 2015

2.15.08.13

2.15.08.13 http://hoa-project.net/

The Hoa\Bench library.

  Sources   Download

BSD-3-Clause

The Requires

 

library time performance trace analyze bench dtrace

29/05 2015

2.15.05.29

2.15.05.29 http://hoa-project.net/

The Hoa\Bench library.

  Sources   Download

BSD-3-Clause

The Requires

 

library time performance trace analyze bench dtrace

13/04 2015

2.15.04.13

2.15.04.13 http://hoa-project.net/

The Hoa\Bench library.

  Sources   Download

BSD-3-Clause

The Requires

 

library time performance trace analyze bench dtrace

17/02 2015

2.15.02.17

2.15.02.17 http://hoa-project.net/

The Hoa\Bench library.

  Sources   Download

BSD-3-Clause

The Requires

 

library time performance trace analyze bench dtrace

09/12 2014

2.14.12.10

2.14.12.10 http://hoa-project.net/

The Hoa\Bench library.

  Sources   Download

BSD-3-Clause

The Requires

 

library time performance trace analyze bench dtrace

20/11 2014

2.14.11.21

2.14.11.21 http://hoa-project.net/

The Hoa\Bench library.

  Sources   Download

BSD-3-Clause

The Requires

 

library time performance trace analyze bench dtrace

09/11 2014

2.14.11.09

2.14.11.09 http://hoa-project.net/

The Hoa\Bench library.

  Sources   Download

BSD-3-Clause

The Requires

 

library time performance trace analyze bench dtrace

23/09 2014

2.14.09.23

2.14.09.23 http://hoa-project.net/

The Hoa\Bench library.

  Sources   Download

BSD-3-Clause

The Requires

 

library time performance trace analyze bench dtrace

17/09 2014

2.14.09.17

2.14.09.17 http://hoa-project.net/

The Hoa\Bench library.

  Sources   Download

BSD-3-Clause

The Requires

 

library time performance trace analyze bench dtrace

16/09 2014

1.14.09.16

1.14.09.16 http://hoa-project.net/

The Hoa\Bench library.

  Sources   Download

BSD-3-Clause

The Requires

 

library time performance trace analyze bench dtrace