This repository has been archived by the owner on Feb 19, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
9 changed files
with
602 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
benchmarks/GeneratedHydratorBenchmark/FileClosure/AllPrivateClassHydrationBench.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); | ||
|
||
namespace GeneratedHydratorBenchmark\FileClosure; | ||
|
||
use GeneratedHydratorBenchmark\Data\AllPrivateClass; | ||
|
||
/** | ||
* Benchmark class that contains only private properties hydration | ||
* | ||
* @BeforeMethods({"setUp"}) | ||
*/ | ||
class AllPrivateClassHydrationBench extends HydrationBench | ||
{ | ||
public function setUp() : void | ||
{ | ||
$this->createHydrator(AllPrivateClass::class); | ||
$this->createData(); | ||
$this->object = new AllPrivateClass(); | ||
} | ||
|
||
/** | ||
* @Revs(100) | ||
* @Iterations(200) | ||
*/ | ||
public function benchConsume() : void | ||
{ | ||
($this->hydrator)($this->data, $this->object); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
benchmarks/GeneratedHydratorBenchmark/FileClosure/AllProtectedClassHydrationBench.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); | ||
|
||
namespace GeneratedHydratorBenchmark\FileClosure; | ||
|
||
use GeneratedHydratorBenchmark\Data\AllProtectedClass; | ||
|
||
/** | ||
* Benchmark class that contains only protected properties hydration | ||
* | ||
* @BeforeMethods({"setUp"}) | ||
*/ | ||
class AllProtectedClassHydrationBench extends HydrationBench | ||
{ | ||
public function setUp() : void | ||
{ | ||
$this->createHydrator(AllProtectedClass::class); | ||
$this->createData(); | ||
$this->object = new AllProtectedClass(); | ||
} | ||
|
||
/** | ||
* @Revs(100) | ||
* @Iterations(200) | ||
*/ | ||
public function benchConsume() : void | ||
{ | ||
($this->hydrator)($this->data, $this->object); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
benchmarks/GeneratedHydratorBenchmark/FileClosure/AllPublicClassHydrationBench.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); | ||
|
||
namespace GeneratedHydratorBenchmark\FileClosure; | ||
|
||
use GeneratedHydratorBenchmark\Data\AllPublicClass; | ||
|
||
/** | ||
* Benchmark class that contains only public properties hydration | ||
* | ||
* @BeforeMethods({"setUp"}) | ||
*/ | ||
class AllPublicClassHydrationBench extends HydrationBench | ||
{ | ||
public function setUp() : void | ||
{ | ||
$this->createHydrator(AllPublicClass::class); | ||
$this->createData(); | ||
$this->object = new AllPublicClass(); | ||
} | ||
|
||
/** | ||
* @Revs(100) | ||
* @Iterations(200) | ||
*/ | ||
public function benchConsume() : void | ||
{ | ||
($this->hydrator)($this->data, $this->object); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
benchmarks/GeneratedHydratorBenchmark/FileClosure/HydrationBench.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,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GeneratedHydratorBenchmark\FileClosure; | ||
|
||
use DateTime; | ||
use GeneratedHydrator\ClosureGenerator\FileCache\GenerateFileCacheHydrator; | ||
use GeneratedHydratorBenchmark\HydrationBench as BaseHydrationBenchAlias; | ||
use stdClass; | ||
|
||
class HydrationBench extends BaseHydrationBenchAlias | ||
{ | ||
/** @var callable */ | ||
protected $hydrator; | ||
|
||
/** @var mixed[] */ | ||
protected $data; | ||
|
||
/** @var mixed */ | ||
protected $object; | ||
|
||
/** | ||
* Create and set the hydrator | ||
*/ | ||
protected function createHydrator(string $class) : void | ||
{ | ||
$this->hydrator = (new GenerateFileCacheHydrator('build/'))($class); | ||
} | ||
|
||
/** | ||
* Populate test data array | ||
*/ | ||
protected function createData() : void | ||
{ | ||
$this->data = [ | ||
'foo' => 'some foo string', | ||
'bar' => 42, | ||
'baz' => new DateTime(), | ||
'someFooProperty' => [12, 13, 14], | ||
'someBarProperty' => 12354.4578, | ||
'someBazProperty' => new stdClass(), | ||
]; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
benchmarks/GeneratedHydratorBenchmark/FileClosure/InheritanceClassHydrationBench.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,47 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GeneratedHydratorBenchmark\RuntimeClosure; | ||
|
||
use DateTime; | ||
use GeneratedHydratorBenchmark\Data\InheritanceClass; | ||
use stdClass; | ||
|
||
/** | ||
* Benchmark class that contains mixed inherited properties hydration | ||
* | ||
* @BeforeMethods({"setUp"}) | ||
*/ | ||
class InheritanceClassHydrationBench extends HydrationBench | ||
{ | ||
protected function createData() : void | ||
{ | ||
parent::createData(); | ||
|
||
$this->data += [ | ||
'foo1' => 'some foo string', | ||
'bar1' => 42, | ||
'baz1' => new DateTime(), | ||
'someFooProperty1' => [12, 13, 14], | ||
'someBarProperty1' => 12354.4578, | ||
'someBazProperty1' => new stdClass(), | ||
]; | ||
} | ||
|
||
public function setUp() : void | ||
{ | ||
$this->createHydrator(InheritanceClass::class); | ||
$this->createData(); | ||
$this->object = new InheritanceClass(); | ||
} | ||
|
||
/** | ||
* @Revs(100) | ||
* @Iterations(200) | ||
*/ | ||
public function benchConsume() : void | ||
{ | ||
($this->hydrator)($this->data, $this->object); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
benchmarks/GeneratedHydratorBenchmark/FileClosure/InheritanceDeepClassHydrationBench.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,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace GeneratedHydratorBenchmark\RuntimeClosure; | ||
|
||
use DateTime; | ||
use GeneratedHydratorBenchmark\Data\InheritanceDeepClass; | ||
use stdClass; | ||
|
||
/** | ||
* Benchmark class that contains mixed deeply inherited properties hydration | ||
* | ||
* @BeforeMethods({"setUp"}) | ||
*/ | ||
class InheritanceDeepClassHydrationBench extends HydrationBench | ||
{ | ||
protected function createData() : void | ||
{ | ||
parent::createData(); | ||
|
||
$this->data += [ | ||
'foo1' => 'some foo string', | ||
'bar1' => 42, | ||
'baz1' => new DateTime(), | ||
'someFooProperty1' => [12, 13, 14], | ||
'someBarProperty1' => 12354.4578, | ||
'someBazProperty1' => new stdClass(), | ||
'foo2' => 'some foo string', | ||
'bar2' => 42, | ||
'baz2' => new DateTime(), | ||
'someFooProperty2' => [12, 13, 14], | ||
'someBarProperty2' => 12354.4578, | ||
'someBazProperty2' => new stdClass(), | ||
]; | ||
} | ||
|
||
public function setUp() : void | ||
{ | ||
$this->createHydrator(InheritanceDeepClass::class); | ||
$this->createData(); | ||
$this->object = new InheritanceDeepClass(); | ||
} | ||
|
||
/** | ||
* @Revs(100) | ||
* @Iterations(200) | ||
*/ | ||
public function benchConsume() : void | ||
{ | ||
($this->hydrator)($this->data, $this->object); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
benchmarks/GeneratedHydratorBenchmark/FileClosure/MixedClassHydrationBench.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); | ||
|
||
namespace GeneratedHydratorBenchmark\RuntimeClosure; | ||
|
||
use GeneratedHydratorBenchmark\Data\MixedClass; | ||
|
||
/** | ||
* Benchmark class that contains public, protected and private properties hydration | ||
* | ||
* @BeforeMethods({"setUp"}) | ||
*/ | ||
class MixedClassHydrationBench extends HydrationBench | ||
{ | ||
public function setUp() : void | ||
{ | ||
$this->createHydrator(MixedClass::class); | ||
$this->createData(); | ||
$this->object = new MixedClass(); | ||
} | ||
|
||
/** | ||
* @Revs(100) | ||
* @Iterations(200) | ||
*/ | ||
public function benchConsume() : void | ||
{ | ||
($this->hydrator)($this->data, $this->object); | ||
} | ||
} |
Oops, something went wrong.