PHP code example of matraux / php-benchmark

1. Go to this page and download the library: Download matraux/php-benchmark 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/ */

    

matraux / php-benchmark example snippets


use Matraux\PhpBenchmark\Benchmark\Benchmark;

$benchmark = new Benchmark;
$benchmark->label = 'Memory peak 20 MB';
$benchmark->counter = 10;
$benchmark->multiplier = 2;

$measurement = $benchmark->run(function (): string {
	return str_repeat(' ', 20 * 1024 * 1024);
});

echo $measurement->average; // Print average time (e.g. 44 ms)
echo $measurement->memory; // Print peak memory usage (e.g. 22 MB)
bash
composer