Skip to content

Commit

Permalink
Merge pull request #36 from bendavies/php-bench
Browse files Browse the repository at this point in the history
replace athletic with phpbench
  • Loading branch information
Ocramius committed Sep 19, 2017
2 parents 185b886 + 34a5e5d commit fe8b2f5
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 35 deletions.
42 changes: 34 additions & 8 deletions .travis.yml
@@ -1,18 +1,44 @@
dist: trusty
sudo: false
language: php

php:
- 7.1
- nightly

before_script:
before_install:
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
- composer self-update
- composer update

install: travis_retry composer update --prefer-dist

script:
- ./vendor/bin/phpunit --coverage-clover coverage.clover
- ./vendor/bin/phpcs --standard=PSR2 ./src/ ./tests/
- php -n ./vendor/bin/athletic -p ./tests/DoctrineTest/InstantiatorPerformance/ -f GroupedFormatter
- ./vendor/bin/phpunit -v

jobs:
include:

- stage: Coverage
php: 7.1
before_script:
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
- if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
script:
- ./vendor/bin/phpunit -v --coverage-clover ./build/logs/clover.xml
after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml

- stage: CS
php: 7.1
install: composer require "squizlabs/php_codesniffer:^3.0.2" --dev
script: ./vendor/bin/phpcs --standard=PSR2 ./src/ ./tests/

- stage: Benchmark
php: 7.1
install: composer require "phpbench/phpbench:^0.13.0" --dev
script: php -n ./vendor/bin/phpbench run --iterations=3 --warmup=1 --report=aggregate

after_script:
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
cache:
directories:
- $HOME/.composer/cache
4 changes: 1 addition & 3 deletions composer.json
Expand Up @@ -21,9 +21,7 @@
"require-dev": {
"ext-phar": "*",
"ext-pdo": "*",
"phpunit/phpunit": "^6.2.3",
"squizlabs/php_codesniffer": "^3.0.2",
"athletic/athletic": "~0.1.8"
"phpunit/phpunit": "^6.2.3"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 4 additions & 0 deletions phpbench.json
@@ -0,0 +1,4 @@
{
"bootstrap": "vendor/autoload.php",
"path": "tests/DoctrineTest/InstantiatorPerformance"
}
Expand Up @@ -19,28 +19,26 @@

namespace DoctrineTest\InstantiatorPerformance;

use Athletic\AthleticEvent;
use Doctrine\Instantiator\Instantiator;
use PhpBench\Benchmark\Metadata\Annotations\BeforeMethods;
use PhpBench\Benchmark\Metadata\Annotations\Revs;

/**
* Performance tests for {@see \Doctrine\Instantiator\Instantiator}
*
* @author Marco Pivetta <ocramius@gmail.com>
*
* @BeforeMethods({"init"})
*/
class InstantiatorPerformanceEvent extends AthleticEvent
class InstantiatorPerformanceEvent
{
/**
* @var \Doctrine\Instantiator\Instantiator
*/
private $instantiator;

/**
* {@inheritDoc}
*/
protected function setUp() : void
public function init() : void
{
parent::setUp();

$this->instantiator = new Instantiator();

$this->instantiator->instantiate(__CLASS__);
Expand All @@ -51,47 +49,41 @@ protected function setUp() : void
}

/**
* @iterations 20000
* @baseline
* @group instantiation
* @Revs(20000)
*/
public function testInstantiateSelf() : void
public function benchInstantiateSelf() : void
{
$this->instantiator->instantiate(__CLASS__);
}

/**
* @iterations 20000
* @group instantiation
* @Revs(20000)
*/
public function testInstantiateInternalClass() : void
public function benchInstantiateInternalClass() : void
{
$this->instantiator->instantiate('ArrayObject');
}

/**
* @iterations 20000
* @group instantiation
* @Revs(20000)
*/
public function testInstantiateSimpleSerializableAssetClass() : void
public function benchInstantiateSimpleSerializableAssetClass() : void
{
$this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\SimpleSerializableAsset');
}

/**
* @iterations 20000
* @group instantiation
* @Revs(20000)
*/
public function testInstantiateSerializableArrayObjectAsset() : void
public function benchInstantiateSerializableArrayObjectAsset() : void
{
$this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\SerializableArrayObjectAsset');
}

/**
* @iterations 20000
* @group instantiation
* @Revs(20000)
*/
public function testInstantiateUnCloneableAsset() : void
public function benchInstantiateUnCloneableAsset() : void
{
$this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\UnCloneableAsset');
}
Expand Down

0 comments on commit fe8b2f5

Please sign in to comment.