PHP Класс Lavoiesl\PhpBenchmark\Benchmark

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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 )

Приватные методы

Метод Описание
warmup ( ) Runs an empty test to determine the benchmark overhead and run each test once

Описание методов

add() публичный метод

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
Результат SimpleTest

addTest() публичный метод

public addTest ( AbstractTest $test )
$test AbstractTest

formatResults() публичный метод

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))
Результат array array(array('Test' => $name, 'Time' => '1000 ms', 'Perc' => '100 %'))

guessCount() публичный метод

Average the guessCount of each test, determining the best n
public guessCount ( float $max_seconds ) : integer
$max_seconds float
Результат integer

outputTable() публичный статический метод

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 run ( $output = true )

setCount() публичный метод

public setCount ( $n )