-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"bootstrap": "vendor/autoload.php", | ||
"path": "tests/Xezilaires/Performance", | ||
|
||
"retry_threshold": 5, | ||
"progress": "dots", | ||
|
||
"annotation_import_use": true, | ||
"extensions": [ | ||
"PhpBench\\Extensions\\Dbal\\DbalExtension", | ||
"PhpBench\\Extensions\\XDebug\\XDebugExtension" | ||
], | ||
"storage": "dbal", | ||
"storage.dbal.connection": { | ||
"driver": "pdo_sqlite", | ||
"path": "var/phpbench-history.db" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the xezilaires project. | ||
* | ||
* (c) Dalibor Karlović <dalibor@flexolabs.io> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Xezilaires\Test\Performance; | ||
|
||
use PhpBench\Benchmark\Metadata\Annotations as Bench; | ||
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; | ||
use Symfony\Component\Serializer\Serializer; | ||
use Xezilaires\Bridge\Symfony\Serializer\ObjectSerializer; | ||
use Xezilaires\Metadata\ColumnReference; | ||
use Xezilaires\Metadata\Mapping; | ||
use Xezilaires\Spreadsheet; | ||
use Xezilaires\SpreadsheetIterator; | ||
use Xezilaires\Test\FixtureTrait; | ||
use Xezilaires\Test\Model\Product; | ||
|
||
/** | ||
* @Bench\BeforeMethods({"setUp"}) | ||
*/ | ||
abstract class PerformanceTestCase | ||
{ | ||
use FixtureTrait; | ||
|
||
/** | ||
* @var Mapping | ||
*/ | ||
private $mapping; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->mapping = new Mapping( | ||
Product::class, | ||
[ | ||
'name' => new ColumnReference('A'), | ||
'price' => new ColumnReference('B'), | ||
], | ||
[ | ||
'start' => 2, | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @Bench\Assert(stat="mean", value="10") | ||
* @Bench\Revs(1000) | ||
*/ | ||
public function benchIteratorConstruction(): void | ||
{ | ||
$this->getSpreadsheet($this->fixture('massive.xlsx')); | ||
} | ||
|
||
/** | ||
* @Bench\Assert(stat="mean", value="10") | ||
* @Bench\Revs(1000) | ||
*/ | ||
public function benchIteratorIteration(): void | ||
{ | ||
$iterator = $this->createIterator($this->getSpreadsheet($this->fixture('products.xlsx')), $this->mapping); | ||
|
||
foreach ($iterator as $row) { | ||
} | ||
} | ||
|
||
abstract protected function getSpreadsheet(\SplFileObject $file): Spreadsheet; | ||
|
||
private function createIterator(Spreadsheet $spreadsheet, Mapping $mapping): SpreadsheetIterator | ||
{ | ||
$serializer = new ObjectSerializer(new Serializer([new ObjectNormalizer()])); | ||
|
||
return new SpreadsheetIterator($spreadsheet, $mapping, $serializer); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
tests/Xezilaires/Performance/Spout/SpoutSpreadsheetIteratorBench.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the xezilaires project. | ||
* | ||
* (c) Dalibor Karlović <dalibor@flexolabs.io> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Xezilaires\Test\Performance\Spout; | ||
|
||
use PhpBench\Benchmark\Metadata\Annotations as Bench; | ||
use Xezilaires\Spreadsheet; | ||
use Xezilaires\Test\Performance\PerformanceTestCase; | ||
|
||
/** | ||
* @internal | ||
* | ||
* @small | ||
*/ | ||
final class SpoutSpreadsheetIteratorBench extends PerformanceTestCase | ||
{ | ||
protected function getSpreadsheet(\SplFileObject $file): Spreadsheet | ||
{ | ||
return new \Xezilaires\Bridge\Spout\Spreadsheet($file); | ||
} | ||
} |