Skip to content
This repository has been archived by the owner on Feb 19, 2025. It is now read-only.

[wip] start implement #64 #78

Open
wants to merge 4 commits into
base: 4.2.x
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;
namespace GeneratedHydratorBenchmark\ClassGenerator;

use GeneratedHydratorBenchmark\Data\AllPrivateClass;
use GeneratedHydratorBenchmark\HydrationBench;

/**
* Benchmark class that contains only private properties hydration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;
namespace GeneratedHydratorBenchmark\ClassGenerator;

use GeneratedHydratorBenchmark\Data\AllProtectedClass;
use GeneratedHydratorBenchmark\HydrationBench;

/**
* Benchmark class that contains only protected properties hydration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;
namespace GeneratedHydratorBenchmark\ClassGenerator;

use GeneratedHydratorBenchmark\Data\AllPublicClass;
use GeneratedHydratorBenchmark\HydrationBench;

/**
* Benchmark class that contains only public properties hydration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;
namespace GeneratedHydratorBenchmark\ClassGenerator;

use DateTime;
use GeneratedHydratorBenchmark\Data\InheritanceClass;
use GeneratedHydratorBenchmark\HydrationBench;
use stdClass;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;
namespace GeneratedHydratorBenchmark\ClassGenerator;

use DateTime;
use GeneratedHydratorBenchmark\Data\InheritanceDeepClass;
use GeneratedHydratorBenchmark\HydrationBench;
use stdClass;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;
namespace GeneratedHydratorBenchmark\ClassGenerator;

use GeneratedHydratorBenchmark\Data\MixedClass;
use GeneratedHydratorBenchmark\HydrationBench;

/**
* Benchmark class that contains public, protected and private properties hydration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;
namespace GeneratedHydratorBenchmark\Data;

/**
* Class that contains only private properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;
namespace GeneratedHydratorBenchmark\Data;

/**
* Class that contains only protected properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;
namespace GeneratedHydratorBenchmark\Data;

/**
* Class that contains only public properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;
namespace GeneratedHydratorBenchmark\Data;

/**
* Class that contains mixed inherited properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;
namespace GeneratedHydratorBenchmark\Data;

/**
* Class that contains mixed deeply inherited properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace GeneratedHydratorBenchmark;
namespace GeneratedHydratorBenchmark\Data;

/**
* Class that contains public, protected and private properties
Expand Down
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);
}
}
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);
}
}
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);
}
}
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(),
];
}
}
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);
}
}
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);
}
}
Loading