Hoa central

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


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


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

```json { "require": { "hoa/bench": "~2.0" } } ```

Please, read the website to get more informations about how to install.

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:

```php $bench = new Hoa();

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


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


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

// Print statistics. echo $bench;


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:

```php <?php

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

f(); ```

Then, we can run DTrace like this:

``sh $ exed=hoa core:resolve hoa://Library/Bench/Dtrace/Execution.d –no-verbose` $ 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.


Different documentations can be found on the website: http://hoa-project.net/.


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