Skip to content

Commit

Permalink
tests: Add more benchmarks.
Browse files Browse the repository at this point in the history
(cherry picked from commit 154e07e08e722bb7f0cec10d619df5593db09dde)
  • Loading branch information
drupol committed Jan 7, 2022
1 parent 8d4f63e commit 89510e0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ install-benchmarks:
composer require azjezz/psl:2.0.x-dev --ignore-platform-reqs

benchmarks: install-benchmarks ## run benchmarks
./vendor/bin/phpbench run
./vendor/bin/phpbench run --profile=local --group=others

create-benchmark-reference: install-benchmarks ## run benchmarks, mark current run as "reference"
./vendor/bin/phpbench run --tag=benchmark_reference
./vendor/bin/phpbench run --profile=local --group=others --tag=benchmark_reference

compare-benchmark-to-reference: ## run benchmarks, compare result to the "reference" run
./vendor/bin/phpbench run --ref=benchmark_reference
./vendor/bin/phpbench run --profile=local --group=others --ref=benchmark_reference
26 changes: 23 additions & 3 deletions tests/benchmarks/CachingIteratorsAggregateBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
use Psl\Iter\Iterator as IterIterator;
use Traversable;

/**
* @Groups({"CachingIteratorsAggregateBench"})
*/
final class CachingIteratorsAggregateBench extends IteratorBenchmark
{
/**
* @Groups({"ci", "local"})
* @ParamProviders("provideGenerators")
*/
public function bench(array $params): void
Expand All @@ -33,10 +31,32 @@ public function bench(array $params): void
);
}

/**
* @Groups({"others"})
* @ParamProviders("provideGeneratorsWithOthers")
*/
public function benchWithOthers(array $params): void
{
$this->doBench(
$this->getSubject($params),
$params
);
}

public function provideGenerators(): Generator
{
$items = 5000;

yield 'CachingIteratorAggregate' => [
'class' => CachingIteratorAggregate::class,
'size' => $items,
];
}

public function provideGeneratorsWithOthers(): Generator
{
$items = 5000;

yield SimpleCachingIteratorAggregate::class => [
'class' => SimpleCachingIteratorAggregate::class,
'size' => $items,
Expand Down

0 comments on commit 89510e0

Please sign in to comment.