Skip to content

Commit

Permalink
Change namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
bakura10 committed May 17, 2014
1 parent 9facb59 commit ec38ed5
Show file tree
Hide file tree
Showing 66 changed files with 1,222 additions and 207 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- hhvm
- hhvm-nightly

before_script:
- composer self-update
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license.
*/

namespace HydratorBenchmark;

use Athletic\AthleticEvent;
use Hydrator\ArraySerializableHydrator;
use Hydrator\Context\HydrationContext;
use HydratorBenchmark\Asset\ArraySerializableObject;

class ArraySerializableHydratorBenchmark extends AthleticEvent
{
/**
* @var ArraySerializableHydrator
*/
protected $hydrator;

public function __construct()
{
$this->hydrator = new ArraySerializableHydrator();
}

/**
* @iterations 100
*/
public function hydratorExtractionWithTwentyProperties()
{
$object = new ArraySerializableObject();
$this->hydrator->extract($object);
}

/**
* @iterations 100
*/
public function hydratorExtractionReusingHydratorWithTwentyProperties()
{
for ($i = 0 ; $i != 20 ; ++$i) {
$object = new ArraySerializableObject();
$this->hydrator->extract($object);
}
}

/**
* @iterations 100
*/
public function hydratorHydrationWithTwentyProperties()
{
$object = new ArraySerializableObject();
$data = [
'one' => 1, 'two' => 2, 'three' => 3, 'four' => 4, 'five' => 5,
'six' => 6, 'seven' => 7, 'eight' => 8, 'nine' => 9, 'ten' => 10,
'eleven' => 11, 'twelve' => 12, 'thirteen' => 13, 'fourteen' => 14, 'fifteen' => 15,
'sixteen' => 16, 'seventeen' => 17, 'eighteen' => 18, 'nineteen' => 19, 'twenty' => 19
];

$this->hydrator->hydrate($data, $object);
}

/**
* @iterations 100
*/
public function hydratorHydrationReusingHydratorWithTwentyProperties()
{
for ($i = 0 ; $i != 20 ; ++$i) {
$object = new ArraySerializableObject();
$data = [
'one' => 1, 'two' => 2, 'three' => 3, 'four' => 4, 'five' => 5,
'six' => 6, 'seven' => 7, 'eight' => 8, 'nine' => 9, 'ten' => 10,
'eleven' => 11, 'twelve' => 12, 'thirteen' => 13, 'fourteen' => 14, 'fifteen' => 15,
'sixteen' => 16, 'seventeen' => 17, 'eighteen' => 18, 'nineteen' => 19, 'twenty' => 19
];

$this->hydrator->hydrate($data, $object);
}
}
}
62 changes: 62 additions & 0 deletions benchmarks/HydratorBenchmark/Asset/ArraySerializableObject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license.
*/

namespace HydratorBenchmark\Asset;

class ArraySerializableObject
{
protected $one = 'one';
protected $two = 'two';
protected $three = 'three';
protected $four = 'four';
protected $five = 'five';
protected $six = 'six';
protected $seven = 'seven';
protected $eight = 'eight';
protected $nine = 'nine';
protected $ten = 'ten';
protected $eleven = 'eleven';
protected $twelve = 'twelve';
protected $thirteen = 'thirteen';
protected $fourteen = 'fourteen';
protected $fifteen = 'fifteen';
protected $sixteen = 'sixteen';
protected $seventeen = 'seventeen';
protected $eighteen = 'eighteen';
protected $nineteen = 'nineteen';
protected $twenty = 'twenty';

public function getArrayCopy()
{
return [
'one' => $this->one, 'two' => $this->two, 'three' => $this->three, 'four' => $this->four,
'five' => $this->five, 'six' => $this->six, 'seven' => $this->seven, 'eight' => $this->eight,
'nine' => $this->nine, 'ten' => $this->ten, 'eleven' => $this->eleven, 'twelve' => $this->twelve,
'thirteen' => $this->thirteen, 'fourteen' => $this->fourteen, 'fifteen' => $this->fifteen,
'sixteen' => $this->sixteen, 'seventeen' => $this->seventeen, 'eighteen' => $this->eighteen,
'nineteen' => $this->nineteen, 'twenty' => $this->twenty
];
}

public function populate(array $data)
{
foreach ($data as $key => $value) {
$this->$key = $value;
}
}
}

0 comments on commit ec38ed5

Please sign in to comment.