PHP code example of mindplay / benchpress

1. Go to this page and download the library: Download mindplay/benchpress library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mindplay / benchpress example snippets


    use mindplay\benchpress\Benchmark;

    $bench = new Benchmark();

    // Benchmark a function and get the result immediately:

    $time = $bench->mark(
        function () {
            // do the work...
        }
    );

    use mindplay\benchpress\Benchmark;

    $bench = new Benchmark();

    // Queue up functions to be benchmarked:

    $bench->add(
        "Description of work",
        function () {
            // do the work...
        }
    );

    $bench->add(...);
    $bench->add(...);
    $bench->add(...);

    // Run the queued functions and generate a report:

    $bench->run();