You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vonglasow 594e8e8d39
Merge pull request #17 from vonglasow/tests
2 years ago
Documentation refactor: rename isRunning to isStarted 3 years ago
Dtrace Quality: Happy new year! 3 years ago
Test/Unit Complete assertions for the first test 2 years ago
.State Add the state of the library. 6 years ago
.gitignore Add a `.gitignore` file. 4 years ago
.travis.yml chore(Bors) Configuring Bors-ng 2 years ago
Bench.php refactor: rename isRunning to isStarted 3 years ago Prepare 3 years ago
Exception.php Quality: Happy new year! 3 years ago
Mark.php refactor: rename isRunning to isStarted 3 years ago Documentation: New `` file. 3 years ago
bors.toml chore(Bors) Configuring Bors-ng 2 years ago
composer.json Complete assertions for the first test 2 years ago


Build status Code coverage Packagist License

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


Help on IRC Help on Gitter Documentation Board

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

Learn more.


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

$ composer require hoa/bench '~3.0'

For more installation procedures, please read the Source page.


Before running the test suites, the development dependencies must be installed:

$ composer install

Then, to run all the test suites:

$ vendor/bin/hoa test:run

For more information, please read the contributor guide.

Quick usage

We propose a quick overview of two usages: The library itself and one DTrace program.


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:

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

// Start two marks: “one” and “two”.


// Stop the mark “two” and start the mark “three”.


// Stop all marks.

// 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.


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:


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


Then, we can run DTrace like this:

$ 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.


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

To generate the documentation locally, execute the following commands:

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

More documentation can be found on the project’s website:

Getting help

There are mainly two ways to get help:


Do you want to contribute? Thanks! A detailed contributor guide explains everything you need to know.


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

The following projects are using this library: