Benchmark Package provide basic functionality for benchmarking.

Installation

With Composer

composer require glowy/benchmark

Usage

use function Glowy\Benchmark\benchmarkStart;
use function Glowy\Benchmark\benchmarkEnd;
use function Glowy\Benchmark\benchmarkSummary;

benchmarkStart('create entry');

// create a new entry...

benchmarkEnd('create entry');

$summary = benchmarkSummary();

print_r($summary);

/*
^ array:1 [
  "create entry" => array:2 [
    "time" => array:4 [
      "prob_start" => 1665240902.4886
      "prob_end" => 1665240903.4918
      "elapsed" => 1.0031571388245
      "elapsed_formated" => "1.003s"
    ]
    "memory" => array:4 [
      "prob_start" => 5777568
      "prob_end" => 5778264
      "usage" => 696
      "usage_formated" => "696B"
    ]
  ]
]
*/
delete Delete benchmark prob.
end End benchmark prob.
flush Flush benchmark prob.
start Start benchmark prob.
summary Get benchmark summary.