-
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
6 changed files
with
140 additions
and
13 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,19 @@ | ||
{ | ||
"bootstrap": "vendor/autoload.php", | ||
"path": "tests/Xezilaires/Performance", | ||
|
||
"retry_threshold": 5, | ||
"progress": "dots", | ||
|
||
"annotation_import_use": true, | ||
"php_disable_ini": 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?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; | ||
|
||
/** | ||
* Trait FixtureLoaderTrait. | ||
*/ | ||
trait FixtureLoaderTrait | ||
{ | ||
/** | ||
* @param string $name | ||
* | ||
* @return \SplFileObject | ||
*/ | ||
private function fixture(string $name): \SplFileObject | ||
{ | ||
return new \SplFileObject(__DIR__.'/../../resources/fixtures/'.$name); | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
tests/Xezilaires/Performance/PhpSpreadsheetIteratorConstructionBench.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,83 @@ | ||
<?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 Xezilaires\Metadata\ColumnReference; | ||
use Xezilaires\Metadata\Mapping; | ||
use Xezilaires\PhpSpreadsheetIterator; | ||
use Xezilaires\Test\FixtureLoaderTrait; | ||
use Xezilaires\Test\Model\Product; | ||
|
||
/** | ||
* @Bench\BeforeMethods({"setUp"}) | ||
*/ | ||
class PhpSpreadsheetIteratorConstructionBench | ||
{ | ||
use FixtureLoaderTrait; | ||
|
||
/** | ||
* @var \SplFileObject | ||
*/ | ||
private $fixture; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->fixture = $this->fixture('products.xls'); | ||
} | ||
|
||
/** | ||
* @Bench\Assert(stat="mean", value="10") | ||
* @Bench\Revs(1000) | ||
*/ | ||
public function benchIteratorConstruction(): void | ||
{ | ||
new PhpSpreadsheetIterator( | ||
$this->fixture, | ||
new Mapping( | ||
Product::class, | ||
[ | ||
'name' => new ColumnReference('A'), | ||
'price' => new ColumnReference('B'), | ||
], | ||
[ | ||
'start' => 2, | ||
] | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* @Bench\Assert(stat="mean", value="1500") | ||
* @Bench\Revs(100) | ||
*/ | ||
public function benchIteratorIteration(): void | ||
{ | ||
$iterator = new PhpSpreadsheetIterator( | ||
$this->fixture, | ||
new Mapping( | ||
Product::class, | ||
[ | ||
'name' => new ColumnReference('A'), | ||
'price' => new ColumnReference('B'), | ||
], | ||
[ | ||
'start' => 2, | ||
] | ||
) | ||
); | ||
|
||
iterator_to_array($iterator); | ||
} | ||
} |
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