Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ jobs:

php: 7.2

env: WITH_LOWEST=true
env: WITH_LOWEST=true WITH_EXAMPLES=true

before_install:
- source .travis/xdebug.sh
- xdebug-disable
- composer validate

install:
- if [[ "$TRAVIS_PHP_VERSION" == "7.3" ]]; then composer remove --dev friendsofphp/php-cs-fixer; fi
- composer remove --dev friendsofphp/php-cs-fixer --no-update
- if [[ "$WITH_LOWEST" == "true" ]]; then composer update --prefer-lowest; fi
- if [[ "$WITH_HIGHEST" == "true" ]]; then composer update; fi

Expand All @@ -66,7 +66,7 @@ jobs:
script:
- vendor/bin/phpunit
- bin/phpbench run --report=env --progress=dots
- bin/phpbench run --profile=examples --report=env --progress=dots
- if [[ "$NO_EXAMPLES" == "false" ]]; then bin/phpbench run --profile=examples --report=env --progress=dots; fi

- <<: *TEST

Expand All @@ -86,6 +86,12 @@ jobs:

env: WITH_HIGHEST=true

- <<: *TEST

php: nightly

env: WITH_HIGHEST=true WITH_EXAMPLES=false

- stage: Deploy

if: (NOT type IN (pull_request)) AND (branch = master)
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^7.2",
"php": "^7.2|^8.0",
"ext-dom": "*",
"ext-json": "*",
"ext-pcre": "*",
Expand All @@ -18,9 +20,8 @@
"beberlei/assert": "^2.4 || ^3.0",
"doctrine/annotations": "^1.2.7",
"doctrine/lexer": "^1.2",
"lstrojny/functional-php": "^1.14",
"phpbench/container": "^1.2.1",
"phpbench/dom": "~0.2.0",
"phpbench/dom": "~0.3.0",
"seld/jsonlint": "^1.1",
"symfony/console": "^4.2 || ^5.0",
"symfony/filesystem": "^4.2 || ^5.0",
Expand All @@ -36,7 +37,7 @@
"padraic/phar-updater": "^1.0",
"phpspec/prophecy": "^1.11",
"phpstan/phpstan": "^0.12.7",
"phpunit/phpunit": "^8.5.8",
"phpunit/phpunit": "^8.5.8|^9.0",
"symfony/var-dumper": "^4.0||^5.0"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion extensions/xdebug/tests/Unit/XDebugUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use PhpBench\Model\ParameterSet;
use PhpBench\Model\Subject;
use PhpBench\Model\Variant;
use PHPUnit\Framework\TestCase;
use PhpBench\Tests\TestCase;

class XDebugUtilTest extends TestCase
{
Expand Down
1 change: 1 addition & 0 deletions lib/Benchmark/Baseline/Baselines.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static function nothing($revs): void
public static function md5($revs): void
{
for ($i = 0; $i < $revs; $i++) {
/** @phpstan-ignore-next-line */
md5('lorem ipusm');
}
}
Expand Down
4 changes: 0 additions & 4 deletions lib/Benchmark/CartesianParameterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ public function next()

$this->index++;
$this->update();

return $this->getParameterSet();
}

public function key(): string
Expand All @@ -82,8 +80,6 @@ public function rewind()
$set->rewind();
}
$this->update();

return $this->current();
}

public function valid(): bool
Expand Down
4 changes: 3 additions & 1 deletion lib/Benchmark/Remote/Reflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ private function getClassNameFromFile(string $file): ?string
for (; $i < count($tokens); $i++) {
if ($tokens[$i][0] === T_NAMESPACE) {
for ($j = $i + 1; $j < count($tokens); $j++) {
if ($tokens[$j][0] === T_STRING) {
$tokenId = $tokens[$j][0];

if ($tokenId === T_STRING || $tokenId === 314) {
$namespace .= '\\' . $tokens[$j][1];
} elseif ($tokens[$j] === '{' || $tokens[$j] === ';') {
break;
Expand Down
49 changes: 49 additions & 0 deletions lib/Functional/Functional.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace PhpBench\Functional;

/**
* These functions lifted directly from lstrojny/functional in order to break
* the dependency and enable PHP8.0 support.
*/
class Functional
{
public static function group(iterable $collection, callable $callback): iterable
{
$groups = [];

foreach ($collection as $index => $element) {
$groupKey = $callback($element, $index, $collection);

if (!isset($groups[$groupKey])) {
$groups[$groupKey] = [];
}

$groups[$groupKey][$index] = $element;
}

return $groups;
}

public static function map(iterable $collection, callable $callback): iterable
{
$aggregation = [];

foreach ($collection as $index => $element) {
$aggregation[$index] = $callback($element, $index, $collection);
}

return $aggregation;
}

/**
*/
public static function reduceLeft(iterable $collection, callable $callback, $initial = null)
{
foreach ($collection as $index => $value) {
$initial = $callback($value, $index, $collection, $initial);
}

return $initial;
}
}
24 changes: 11 additions & 13 deletions lib/Report/Generator/TableGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@

namespace PhpBench\Report\Generator;

use function Functional\group;
use function Functional\map;
use function Functional\reduce_left;
use PhpBench\Dom\Document;
use PhpBench\Functional\Functional as F;
use PhpBench\Math\Statistics;
use PhpBench\Model\Result\MemoryResult;
use PhpBench\Model\Result\TimeResult;
Expand Down Expand Up @@ -141,13 +139,13 @@ private function processDiffs(array $tables, Config $config): array
));
}

return map($tables, function ($table) use ($stat) {
$means = map($table, function (Row $row) use ($stat) {
return F::map($tables, function ($table) use ($stat) {
$means = F::map($table, function (Row $row) use ($stat) {
return $row->getValue($stat);
});
$min = min($means);

return map($table, function (Row $row) use ($min, $stat) {
return F::map($table, function (Row $row) use ($min, $stat) {
if ($min === 0 || $min === 0.0) {
$row->setValue('diff', 0);

Expand Down Expand Up @@ -227,7 +225,7 @@ private function processBreak(array $table, Config $config): array
}
}

return group($table, function (Row $row) use ($break) {
return F::group($table, function (Row $row) use ($break) {
$breakHash = [];

foreach ($break as $breakKey) {
Expand Down Expand Up @@ -260,8 +258,8 @@ private function processCols(array $tables, Config $config): array
$cols = array_merge($cols, $config['compare_fields']);
}

$tables = map($tables, function ($table) use ($cols) {
return map($table, function (Row $row) use ($cols) {
$tables = F::map($tables, function ($table) use ($cols) {
return F::map($table, function (Row $row) use ($cols) {
$newRow = $row->newInstance([]);

foreach ($cols as $col) {
Expand Down Expand Up @@ -296,11 +294,11 @@ private function processCompare(array $tables, Config $config): array
$compare = $config['compare'];
$compareFields = $config['compare_fields'];

return map($tables, function ($table) use ($conditions, $compare, $compareFields) {
$groups = group($table, function (Row $row) use ($conditions) {
return F::map($tables, function ($table) use ($conditions, $compare, $compareFields) {
$groups = F::group($table, function (Row $row) use ($conditions) {
$values = array_intersect_key($row->toArray(), array_flip($conditions));

return reduce_left($values, function ($value, $i, $c, $reduction) {
return F::reduceLeft($values, function ($value, $i, $c, $reduction) {
return $reduction . $value;
});
});
Expand Down Expand Up @@ -353,7 +351,7 @@ private function processCompare(array $tables, Config $config): array
$table[] = $firstRow;
}

$table = map($table, function (Row $row) use ($colNames) {
$table = F::map($table, function (Row $row) use ($colNames) {
$newRow = $row->newInstance([]);

foreach ($colNames as $colName) {
Expand Down
7 changes: 0 additions & 7 deletions lib/Serializer/XmlDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public function decode(Document $document): SuiteCollection
$suites = [];

foreach ($document->query('//suite') as $suiteEl) {
/** @phpstan-ignore-next-line */
$suites[] = $this->processSuite($suiteEl);
}

Expand Down Expand Up @@ -119,7 +118,6 @@ private function processSuite(Element $suiteEl): Suite
$benchmarkEl->getAttribute('class')
);

/** @phpstan-ignore-next-line */
$this->processBenchmark($benchmark, $benchmarkEl, $resultClasses);
}

Expand All @@ -130,7 +128,6 @@ private function processBenchmark(Benchmark $benchmark, Element $benchmarkEl, ar
{
foreach ($benchmarkEl->query('./subject') as $subjectEl) {
$subject = $benchmark->createSubject($subjectEl->getAttribute('name'));
/** @phpstan-ignore-next-line */
$this->processSubject($subject, $subjectEl, $resultClasses);
}
}
Expand All @@ -145,7 +142,6 @@ private function processSubject(Subject $subject, Element $subjectEl, array $res
$subject->setGroups($groups);

foreach ($subjectEl->query('./executor') as $executorEl) {
/** @phpstan-ignore-next-line */
$subject->setExecutor(ResolvedExecutor::fromNameAndConfig($executorEl->getAttribute('name'), new Config('asd', $this->getParameters($executorEl))));

break;
Expand Down Expand Up @@ -173,10 +169,8 @@ private function processSubject(Subject $subject, Element $subjectEl, array $res

break;
}
/** @phpstan-ignore-next-line */
$stats = $this->getComputedStats($variantEl);
$variant = $subject->createVariant($parameterSet, (int)$variantEl->getAttribute('revs'), (int)$variantEl->getAttribute('warmup'), $stats);
/** @phpstan-ignore-next-line */
$this->processVariant($variant, $variantEl, $resultClasses);
}
}
Expand All @@ -202,7 +196,6 @@ private function getParameters(Element $element): array
$name = $parameterEl->getAttribute('name');

if ($parameterEl->getAttribute('type') === 'collection') {
/** @phpstan-ignore-next-line */
$parameters[$name] = $this->getParameters($parameterEl);

continue;
Expand Down
2 changes: 1 addition & 1 deletion lib/Storage/Driver/Fake/FakeHistoryIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function current()
*/
public function next()
{
return next($this->entries);
next($this->entries);
}

/**
Expand Down
6 changes: 1 addition & 5 deletions lib/Storage/Driver/Xml/HistoryIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,7 @@ private function getEntryIterator(): \ArrayIterator
$historyEntries[] = $this->getHistoryEntry($file->getPathname());
}
usort($historyEntries, function ($entry1, $entry2) {
if ($entry1->getDate()->format('U') === $entry2->getDate()->format('U')) {
return;
}

return $entry1->getDate()->format('U') < $entry2->getDate()->format('U');
return $entry2->getDate()->format('U') <=> $entry1->getDate()->format('U');
});

return new \ArrayIterator($historyEntries);
Expand Down
2 changes: 0 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
parameters:
level: 5
ignoreErrors:
- '#Call to an undefined method DOMNode#'
paths:
- lib
includes:
Expand Down
1 change: 0 additions & 1 deletion tests/Functional/FunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace PhpBench\Tests\Functional;

use PhpBench\DependencyInjection\Container;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Filesystem\Filesystem;

/**
Expand Down
1 change: 0 additions & 1 deletion tests/IntegrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace PhpBench\Tests;

use PhpBench\Tests\Util\Workspace;
use PHPUnit\Framework\TestCase;

class IntegrationTestCase extends TestCase
{
Expand Down
1 change: 0 additions & 1 deletion tests/PhpBenchTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace PhpBench\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Filesystem\Filesystem;

class PhpBenchTestCase extends TestCase
Expand Down
Loading