PHP code example of spencer-mortensen / benchmarker

1. Go to this page and download the library: Download spencer-mortensen/benchmarker 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/ */

    

spencer-mortensen / benchmarker example snippets


use SpencerMortensen\Benchmarker\Test;

class ArrayTest implements Test
{
	public function run()
	{
		$t0 = microtime(true);

		array(
			'first' => 'Ann',
			'last' => 'Baker'
		);

		$t1 = microtime(true);

		return $t1 - $t0;
	}
}

$benchmarker = new Benchmarker();

$tests = array(
	'array' => array(new ArrayTest(), 10000),
);

$results = $benchmarker->run($tests);

echo $results, "\n"; // array: 5.0E-7 +- 1.1E-6