src/Reporter/Text.php
public function table()
    {
        $ranking = $this->_benchmark->matrix()->ranking();
        $matrix = $this->_benchmark->matrix()->matrix();

        if (!$ranking) {
            return;
        }

        $columnLength = [];
        $maxLength = 0;
        foreach($ranking as $task) {
            $name = $task->name();
            if (preg_match('~^([\w\s]+)~', $name, $matches)) {
                $columnLength[$name] = mb_strlen(trim($matches[1]));
            } else {
                $columnLength[$name] = mb_strlen($name);
            }
            if (mb_strlen($name) > $maxLength){
                $maxLength = mb_strlen($name);
            }
        }

        $result = '';
        $result .= $this->mb_str_pad('', $maxLength);
        $result .= $this->mb_str_pad('Rate', 10);
        $result .= $this->mb_str_pad('Mem', 8);

        foreach($ranking as $task) {
            $name = $task->name();
            if (preg_match('~^([\w\s]+)~', $name, $matches)) {
                $result .= $this->mb_str_pad(trim($matches[1]), $columnLength[$name] + 2);
            } else {
                $result .= $this->mb_str_pad($name, $columnLength[$name] + 2);
            }
        }
        $result .= "\n";

        foreach($ranking as $task1) {
            $name1 = $task1->name();
            $result .= $this->mb_str_pad($name1, $maxLength, ' ', STR_PAD_RIGHT);
            $task1 = $this->_benchmark->task($name1);

            $result .= $this->mb_str_pad($this->readableSize($task1->rate()) . '/s', 10);
            $result .= $this->mb_str_pad($this->readableSize($task1->memory(), 0, 1024) . 'B', 8);

            foreach($ranking as $task2) {
                $name2 = $task2->name();
                if ($task1->failed() || $task2->failed()) {
                    $result .= $this->mb_str_pad('x', $columnLength[$name2] + 2);
                } else {
                    $percent = $matrix[$name1][$name2] !== 100 ? $matrix[$name1][$name2] : '--';
                    $result .= $this->mb_str_pad($percent . '%', $columnLength[$name2] + 2);
                }
            }
            $result .= "\n";
        }
        return $result;
    }
public function table()
    {
        $ranking = $this->_benchmark->matrix()->ranking();
        $matrix = $this->_benchmark->matrix()->matrix();

        if (!$ranking) {
            return;
        }

        $columnLength = [];
        $maxLength = 0;
        foreach($ranking as $task) {
            $name = $task->name();
            if (preg_match('~^([\w\s]+)~', $name, $matches)) {
                $columnLength[$name] = mb_strlen(trim($matches[1]));
            } else {
                $columnLength[$name] = mb_strlen($name);
            }
            if (mb_strlen($name) > $maxLength){
                $maxLength = mb_strlen($name);
            }
        }

        $result = '';
        $result .= $this->mb_str_pad('', $maxLength);
        $result .= $this->mb_str_pad('Rate', 10);
        $result .= $this->mb_str_pad('Mem', 8);

        foreach($ranking as $task) {
            $name = $task->name();
            if (preg_match('~^([\w\s]+)~', $name, $matches)) {
                $result .= $this->mb_str_pad(trim($matches[1]), $columnLength[$name] + 2);
            } else {
                $result .= $this->mb_str_pad($name, $columnLength[$name] + 2);
            }
        }
        $result .= "\n";

        foreach($ranking as $task1) {
            $name1 = $task1->name();
            $result .= $this->mb_str_pad($name1, $maxLength, ' ', STR_PAD_RIGHT);
            $task1 = $this->_benchmark->task($name1);

            $result .= $this->mb_str_pad($this->readableSize($task1->rate()) . '/s', 10);
            $result .= $this->mb_str_pad($this->readableSize($task1->memory(), 0, 1024) . 'B', 8);

            foreach($ranking as $task2) {
                $name2 = $task2->name();
                if ($task1->failed() || $task2->failed()) {
                    $result .= $this->mb_str_pad('x', $columnLength[$name2] + 2);
                } else {
                    $percent = $matrix[$name1][$name2] !== 100 ? $matrix[$name1][$name2] : '--';
                    $result .= $this->mb_str_pad($percent . '%', $columnLength[$name2] + 2);
                }
            }
            $result .= "\n";
        }
        return $result;
    }
public function table ( ) { $ ranking = $ this -> _benchmark -> matrix ( ) -> ranking ( ) ; $ matrix = $ this -> _benchmark -> matrix ( ) -> matrix ( ) ; if ( ! $ ranking ) { return ; } $ columnLength = [ ] ; $ maxLength = 0 ; foreach ( $ ranking as $ task ) { $ name = $ task -> name ( ) ; if ( preg_match ( '~^([\w\s]+)~' , $ name , $ matches ) ) { $ columnLength [ $ name ] = mb_strlen ( trim ( $ matches [ 1 ] ) ) ; } else { $ columnLength [ $ name ] = mb_strlen ( $ name ) ; } if ( mb_strlen ( $ name ) > $ maxLength ) { $ maxLength = mb_strlen ( $ name ) ; } } $ result = '' ; $ result .= $ this -> mb_str_pad ( '' , $ maxLength ) ; $ result .= $ this -> mb_str_pad ( 'Rate' , 10 ) ; $ result .= $ this -> mb_str_pad ( 'Mem' , 8 ) ; foreach ( $ ranking as $ task ) { $ name = $ task -> name ( ) ; if ( preg_match ( '~^([\w\s]+)~' , $ name , $ matches ) ) { $ result .= $ this -> mb_str_pad ( trim ( $ matches [ 1 ] ) , $ columnLength [ $ name ] + 2 ) ; } else { $ result .= $ this -> mb_str_pad ( $ name , $ columnLength [ $ name ] + 2 ) ; } } $ result .= "\n" ; foreach ( $ ranking as $ task1 ) { $ name1 = $ task1 -> name ( ) ; $ result .= $ this -> mb_str_pad ( $ name1 , $ maxLength , ' ' , STR_PAD_RIGHT ) ; $ task1 = $ this -> _benchmark -> task ( $ name1 ) ; $ result .= $ this -> mb_str_pad ( $ this -> readableSize ( $ task1 -> rate ( ) ) . '/s' , 10 ) ; $ result .= $ this -> mb_str_pad ( $ this -> readableSize ( $ task1 -> memory ( ) , 0 , 1024 ) . 'B' , 8 ) ; foreach ( $ ranking as $ task2 ) { $ name2 = $ task2 -> name ( ) ; if ( $ task1 -> failed ( ) || $ task2 -> failed ( ) ) { $ result .= $ this -> mb_str_pad ( 'x' , $ columnLength [ $ name2 ] + 2 ) ; } else { $ percent = $ matrix [ $ name1 ] [ $ name2 ] !== 100 ? $ matrix [ $ name1 ] [ $ name2 ] : '--' ; $ result .= $ this -> mb_str_pad ( $ percent . '%' , $ columnLength [ $ name2 ] + 2 ) ; } } $ result .= "\n" ; } return $ result ; }
Returns the report.

@return string The report.
Returns the report .