hoaproject/Bench

If the execution is < 1ms then global > 100 %

maitrepylos opened this issue · 2 comments

Sample :

use Hoa\Bench;


$tab = \SplFixedArray::fromArray(['Gg', 'est', 'le', 'plus', 'beau']);

$bench = new Bench();

$bench->one->start();

for($i=0;$i<$tab->count();$i++){

    echo $tab[$i];

}

$bench->one->stop();


$bench->two->start();

//le foreach

foreach($tab as $value){

    echo $value;
}

$bench->two->stop();


echo $bench;

Result :

global |||||||||||||||||||||||||||||||||||||||||||||||||||||| 0ms, 104.1%
one |||||||||||||||||||||| 0ms, 43.2%
two |||||||||| 0ms, 19.1%

1e1 commented

I suggest adding pause() and resume(). Then getStatistic() will call these methods to loop on paused Marks.

Hywan commented

@1e1 Agree.