Benchmark

The Benchmark class is a lite cli tool for benchmarking codes. It uses a static method fn to run series of code lines and then it tries to generate benchmark table for each code group it executes. An example of this is shown below:

Initializing class
The benchmark tool can be easily initialized as shown below.

Sample code: Benchmark
    \spoova\mi\core\classes\Benchmark::fn([

        'querie' => function(){
            $Hasher = new \spoova\mi\core\classes\Hasher;
            $Hasher->setHash(['loomars'], '1234');
            $hash = $Hasher->hashify();
        },

        'querier' => function(){
            for($i = 0; $i <= 99999; $i++){
                $Hasher = new \spoova\mi\core\classes\Hasher;
                $Hasher->setHash(['loomars'], '1234');
                $hash = $Hasher->hashify();
            }
        }
        
    ])
                                        
The code above is an example of a benchmark code structure. In order to run this code in the command line, the following process should be followed:
  • Copy the benchmark code from above.
  • Run the cli command php mi :wiz
  • Paste the copied code to the cli.
  • Add a semicolon delimiter to a new line to declare the end of code.
  • Lastly, press enter to process the code.
Once the process above is executed, a benchmark table will be generated for each of the array keys "querie" and "querier".