Ness PHP Benchmarking Class
Required Namespace
  • Ness
    • Tool
      • Benchmark

You can include this library to your code file by typing the below code;

use Ness\Tool\Benchmark


About Benchmarking Class #top

You can use Ness framework's benchmarking class to calculate the time elapsed from start point until the end point of your code.


Available Methods #top

Start
                           
use Ness\Tool\Benchmark;
$bm = new Benchmark();
$start = $bm->Start();
    //Your code goes here
    //...
    //...
echo $bm->Finish($start);
                            
This function is used to define a start point for your benchmarking.
Return Float
Parameters None



Finish
                            
 use Ness\Tool\Benchmark;
 $bm = new Benchmark();
 $start = $bm->Start();
     //Your code goes here
     //...
     //...
 echo $bm->Finish($start);
                             
This function is used to define a finish point for your benchmarking. Get's 1 parameter and returns Float. You can set your start variable as parameter.
Return Float
Parameters $start; Benchmarking's class start object.



SavePoint
                             
  use Ness\Tool\Benchmark;
  $bm = new Benchmark();
  $start = $bm->Start();
      //Your code goes here
      //...
      //...
  echo $bm->Finish($start);
  $bm->SavePoint("test_benchmark",$bm->Finish($start));
                              
This function is used to save a benchmarking point to an array. Get's 2 parameters(string, finish_point) and returns void.
Return Void
Parameters $name; Point name;
$end_point; Define a finish to save point.



Points
                             
  use Ness\Tool\Benchmark;
  $bm = new Benchmark();
  $start = $bm->Start();
      //Your code goes here
      //...
      //...
  echo $bm->Finish($start);
  $bm->SavePoint("test_benchmark",$bm->Finish($start));
  var_dump($bm->Points());
                              
This function is used to return array of saved points.
Return Array
Parameters None
The result will be:
                             
array (size=1)
0 => 
array (size=1)
'test_benchmark' => float 0.0001