PhpBench\Report\Generator\TableGenerator::processDiffs PHP Méthode

processDiffs() private méthode

Calculate the diff column if it is displayed.
private processDiffs ( array $tables, Config $config ) : array
$tables array
$config PhpBench\Registry\Config
Résultat array
    private function processDiffs(array $tables, Config $config)
    {
        $stat = $config['diff_col'];
        if ($config['compare']) {
            return $tables;
        }
        if (!in_array('diff', $config['cols'])) {
            return $tables;
        }
        if (!in_array($stat, $config['cols'])) {
            throw new \InvalidArgumentException(sprintf('The "%s" column must be visible when using the diff column', $stat));
        }
        return F\map($tables, function ($table) use($stat) {
            $means = F\map($table, function ($row) use($stat) {
                return $row[$stat];
            });
            $min = min($means);
            return F\map($table, function ($row) use($min, $stat) {
                if ($row[$stat] === 0) {
                    $row['diff'] = 0;
                    return $row;
                }
                $row['diff'] = ($row[$stat] / $min - 1) * 100;
                return $row;
            });
        });
    }