src/Benchmark.php
public function formatResults(array $results)
    {
        uasort($results['list'], function ($testOne, $testTwo) {
            if ($testOne['time'] === $testTwo['time']) {
                return 0;
            } else {
                return ($testOne['time'] < $testTwo['time']) ? -1 : 1;
            }
        });

        $minTime   = INF;
        $minMemory = INF;

        foreach ($results['list'] as $name => $result) {
            // time
            $time = $result['time'];
            //$time -= $this->_overhead['time']; // Substract base_time
            $results['list'][$name]['time'] = $time;

            $minTime = min($minTime, $time);

            // memory
            $memory = $results['list'][$name]['memory'];
            $memory -= $this->_overhead['memory'];
            $results['list'][$name]['memory'] = $memory;

            $minMemory = min($minMemory, $memory);
        }

        $output = array();

        $isOne = count($results['list']) === 1;
        foreach ($results['list'] as $name => $result) {
            if ($isOne) {
                $output[] = array(
                    self::COL_NAME     => $name,
                    self::COL_TIME     => $this->_timeFormat($result['time'], 0),
                    self::COL_TIME_ONE => $this->_timeFormat($result['time'] / $this->_count),
                    self::COL_MEMORY   => FS::format($result['memory'], 2),
                );
            } else {
                $output[] = array(
                    self::COL_NAME       => $name,
                    self::COL_TIME       => $this->_timeFormat($result['time'], 0),
                    self::COL_TIME_ONE   => $this->_timeFormat($result['time'] / $this->_count),
                    self::COL_TIME_REL   => Vars::relativePercent($minTime, $result['time']),
                    self::COL_MEMORY     => FS::format($result['memory'], 2),
                    self::COL_MEMORY_REL => Vars::relativePercent($minMemory, $result['memory']),
                );
            }
        }

        return $output;
    }
public function formatResults(array $results)
    {
        uasort($results['list'], function ($testOne, $testTwo) {
            if ($testOne['time'] === $testTwo['time']) {
                return 0;
            } else {
                return ($testOne['time'] < $testTwo['time']) ? -1 : 1;
            }
        });

        $minTime   = INF;
        $minMemory = INF;

        foreach ($results['list'] as $name => $result) {
            // time
            $time = $result['time'];
            //$time -= $this->_overhead['time']; // Substract base_time
            $results['list'][$name]['time'] = $time;

            $minTime = min($minTime, $time);

            // memory
            $memory = $results['list'][$name]['memory'];
            $memory -= $this->_overhead['memory'];
            $results['list'][$name]['memory'] = $memory;

            $minMemory = min($minMemory, $memory);
        }

        $output = array();

        $isOne = count($results['list']) === 1;
        foreach ($results['list'] as $name => $result) {
            if ($isOne) {
                $output[] = array(
                    self::COL_NAME     => $name,
                    self::COL_TIME     => $this->_timeFormat($result['time'], 0),
                    self::COL_TIME_ONE => $this->_timeFormat($result['time'] / $this->_count),
                    self::COL_MEMORY   => FS::format($result['memory'], 2),
                );
            } else {
                $output[] = array(
                    self::COL_NAME       => $name,
                    self::COL_TIME       => $this->_timeFormat($result['time'], 0),
                    self::COL_TIME_ONE   => $this->_timeFormat($result['time'] / $this->_count),
                    self::COL_TIME_REL   => Vars::relativePercent($minTime, $result['time']),
                    self::COL_MEMORY     => FS::format($result['memory'], 2),
                    self::COL_MEMORY_REL => Vars::relativePercent($minMemory, $result['memory']),
                );
            }
        }

        return $output;
    }
public function formatResults ( array $ results ) { uasort ( $ results [ 'list' ] , function ( $ testOne , $ testTwo ) { if ( $ testOne [ 'time' ] === $ testTwo [ 'time' ] ) { return 0 ; } else { return ( $ testOne [ 'time' ] < $ testTwo [ 'time' ] ) ? - 1 : 1 ; } } ) ; $ minTime = INF ; $ minMemory = INF ; foreach ( $ results [ 'list' ] as $ name => $ result ) { // time $ time = $ result [ 'time' ] ; //$time -= $this->_overhead['time']; // Substract base_time $ results [ 'list' ] [ $ name ] [ 'time' ] = $ time ; $ minTime = min ( $ minTime , $ time ) ; // memory $ memory = $ results [ 'list' ] [ $ name ] [ 'memory' ] ; $ memory -= $ this -> _overhead [ 'memory' ] ; $ results [ 'list' ] [ $ name ] [ 'memory' ] = $ memory ; $ minMemory = min ( $ minMemory , $ memory ) ; } $ output = array ( ) ; $ isOne = count ( $ results [ 'list' ] ) === 1 ; foreach ( $ results [ 'list' ] as $ name => $ result ) { if ( $ isOne ) { $ output [ ] = array ( self :: COL_NAME => $ name , self :: COL_TIME => $ this -> _timeFormat ( $ result [ 'time' ] , 0 ) , self :: COL_TIME_ONE => $ this -> _timeFormat ( $ result [ 'time' ] / $ this -> _count ) , self :: COL_MEMORY => FS :: format ( $ result [ 'memory' ] , 2 ) , ) ; } else { $ output [ ] = array ( self :: COL_NAME => $ name , self :: COL_TIME => $ this -> _timeFormat ( $ result [ 'time' ] , 0 ) , self :: COL_TIME_ONE => $ this -> _timeFormat ( $ result [ 'time' ] / $ this -> _count ) , self :: COL_TIME_REL => Vars :: relativePercent ( $ minTime , $ result [ 'time' ] ) , self :: COL_MEMORY => FS :: format ( $ result [ 'memory' ] , 2 ) , self :: COL_MEMORY_REL => Vars :: relativePercent ( $ minMemory , $ result [ 'memory' ] ) , ) ; } } return $ output ; }
Format the results, rounding numbers, showing difference percentages
and removing a flat time based on the benchmark overhead

@param  array $results array($name => array('time' => 1.0))
@return array array(array('Test' => $name, 'Time' => '1000 ms', 'Perc' => '100 %'))
Format the results rounding numbers showing difference percentages and removing a flat time based on the benchmark overhead