PHP Class Lavoiesl\PhpBenchmark\Benchmark

Afficher le fichier Open project: lavoiesl/php-benchmark Class Usage Examples

Méthodes publiques

Méthode Description
add ( string $name, Closure $closure ) : SimpleTest Utility method to create tests on the fly You may chain the test:
addTest ( AbstractTest $test )
formatResults ( array $results ) : array Format the results, rounding numbers, showing difference percentages and removing a flat time based on the benchmark overhead
guessCount ( float $max_seconds ) : integer Average the guessCount of each test, determining the best n
outputTable ( array $lines, integer $padding = 3 ) Output results in columns, padding right if values are string, left if numeric
run ( $output = true )
setCount ( $n )

Private Methods

Méthode Description
warmup ( ) Runs an empty test to determine the benchmark overhead and run each test once

Method Details

add() public méthode

Utility method to create tests on the fly You may chain the test:
public add ( string $name, Closure $closure ) : SimpleTest
$name string
$closure Closure function to execute
Résultat SimpleTest

addTest() public méthode

public addTest ( AbstractTest $test )
$test AbstractTest

formatResults() public méthode

Format the results, rounding numbers, showing difference percentages and removing a flat time based on the benchmark overhead
public formatResults ( array $results ) : array
$results array array($name => array('time' => 1.0))
Résultat array array(array('Test' => $name, 'Time' => '1000 ms', 'Perc' => '100 %'))

guessCount() public méthode

Average the guessCount of each test, determining the best n
public guessCount ( float $max_seconds ) : integer
$max_seconds float
Résultat integer

outputTable() public static méthode

Output results in columns, padding right if values are string, left if numeric
public static outputTable ( array $lines, integer $padding = 3 )
$lines array array(array('Name' => 'Value'));
$padding integer space between columns

run() public méthode

public run ( $output = true )

setCount() public méthode

public setCount ( $n )