Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.
Merged
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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
.gitignore export-ignore
.travis.yml export-ignore
.composer.lock export-ignore
phpbench.json export-ignore
phpunit.xml.dist export-ignore
12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ env:
global:
- COMPOSER_ARGS="--no-interaction"
- COVERAGE_DEPS="satooshi/php-coveralls"
- LEGACY_DEPS="phpunit/phpunit"

matrix:
include:
Expand All @@ -20,6 +19,7 @@ matrix:
- php: 5.6
env:
- DEPS=locked
- LEGACY_DEPS="phpbench/phpbench phpunit/phpunit"
- php: 5.6
env:
- DEPS=latest
Expand All @@ -29,8 +29,7 @@ matrix:
- php: 7
env:
- DEPS=locked
- CS_CHECK=true
- TEST_COVERAGE=true
- LEGACY_DEPS="phpbench/phpbench phpunit/phpunit"
- php: 7
env:
- DEPS=latest
Expand All @@ -40,6 +39,9 @@ matrix:
- php: 7.1
env:
- DEPS=locked
- CS_CHECK=true
- BENCHMARKS=true
- TEST_COVERAGE=true
- php: 7.1
env:
- DEPS=latest
Expand All @@ -59,19 +61,19 @@ before_install:

install:
- travis_retry composer install $COMPOSER_ARGS --ignore-platform-reqs
- if [[ $TRAVIS_PHP_VERSION =~ ^5.6 ]]; then travis_retry composer update $COMPOSER_ARGS --with-dependencies $LEGACY_DEPS ; fi
- if [[ $LEGACY_DEPS != '' ]]; then travis_retry composer update $COMPOSER_ARGS --with-dependencies $LEGACY_DEPS ; fi
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi
- stty cols 120 && composer show

script:
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi
- if [[ $BENCHMARKS == 'true' ]]; then vendor/bin/phpbench run --revs=2 --iterations=2 --report=aggregate ; fi
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi

after_script:
- if [[ $TEST_COVERAGE == 'true' ]]; then composer upload-coverage ; fi

notifications:
email: false

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,15 @@ class for different scopes like:

- File issues at https://github.com/zendframework/zend-stdlib/issues
- Documentation is at https://docs.zendframework.com/zend-stdlib/

## Benchmarks

We provide scripts for benchmarking zend-stdlib using the
[PHPBench](https://github.com/phpbench/phpbench) framework; these can be
found in the `benchmarks/` directory.

To execute the benchmarks you can run the following command:

```bash
$ vendor/bin/phpbench run --report=aggregate
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@

namespace ZendBench\Stdlib;

use Athletic\AthleticEvent;
use PhpBench\Benchmark\Metadata\Annotations\Iterations;
use PhpBench\Benchmark\Metadata\Annotations\Revs;
use PhpBench\Benchmark\Metadata\Annotations\Warmup;
use Zend\Stdlib\FastPriorityQueue;
use Zend\Stdlib\PriorityQueue;
use Zend\Stdlib\SplPriorityQueue;

class ExtractPriorityQueue extends AthleticEvent
/**
* @Revs(1000)
* @Iterations(10)
* @Warmup(2)
*/
class ExtractPriorityQueueBench
{
public function classSetUp()
public function __construct()
{
$this->splPriorityQueue = new SplPriorityQueue();
$this->fastPriorityQueue = new FastPriorityQueue();
Expand All @@ -30,26 +37,17 @@ public function classSetUp()
}
}

/**
* @iterations 5000
*/
public function extractSplPriorityQueue()
public function benchExtractSplPriorityQueue()
{
$this->splPriorityQueue->extract();
}

/**
* @iterations 5000
*/
public function extractPriorityQueue()
public function benchExtractPriorityQueue()
{
$this->priorityQueue->extract();
}

/**
* @iterations 5000
*/
public function extractFastPriorityQueue()
public function benchExtractFastPriorityQueue()
{
$this->fastPriorityQueue->extract();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,38 @@

namespace ZendBench\Stdlib;

use Athletic\AthleticEvent;
use PhpBench\Benchmark\Metadata\Annotations\Iterations;
use PhpBench\Benchmark\Metadata\Annotations\Revs;
use PhpBench\Benchmark\Metadata\Annotations\Warmup;
use Zend\Stdlib\FastPriorityQueue;
use Zend\Stdlib\PriorityQueue;
use Zend\Stdlib\SplPriorityQueue;

class InsertPriorityQueue extends AthleticEvent
/**
* @Revs(1000)
* @Iterations(10)
* @Warmup(2)
*/
class InsertPriorityQueueBench
{
public function classSetUp()
public function __construct()
{
$this->splPriorityQueue = new SplPriorityQueue();
$this->fastPriorityQueue = new FastPriorityQueue();
$this->priorityQueue = new PriorityQueue();
}

/**
* @iterations 5000
*/
public function insertSplPriorityQueue()
public function benchInsertSplPriorityQueue()
{
$this->splPriorityQueue->insert('foo', rand(1, 100));
}

/**
* @iterations 5000
*/
public function insertPriorityQueue()
public function benchInsertPriorityQueue()
{
$this->priorityQueue->insert('foo', rand(1, 100));
}

/**
* @iterations 5000
*/
public function insertFastPriorityQueue()
public function benchInsertFastPriorityQueue()
{
$this->fastPriorityQueue->insert('foo', rand(1, 100));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@

namespace ZendBench\Stdlib;

use Athletic\AthleticEvent;
use PhpBench\Benchmark\Metadata\Annotations\Iterations;
use PhpBench\Benchmark\Metadata\Annotations\Revs;
use PhpBench\Benchmark\Metadata\Annotations\Warmup;
use Zend\Stdlib\FastPriorityQueue;
use Zend\Stdlib\PriorityQueue;

class RemovePriorityQueue extends AthleticEvent
/**
* @Revs(1000)
* @Iterations(10)
* @Warmup(2)
*/
class RemovePriorityQueueBench
{
public function classSetUp()
public function __construct()
{
$this->fastPriorityQueue = new FastPriorityQueue();
$this->priorityQueue = new PriorityQueue();
Expand All @@ -27,18 +34,12 @@ public function classSetUp()
}
}

/**
* @iterations 1000
*/
public function removePriorityQueue()
public function benchRemovePriorityQueue()
{
$this->priorityQueue->remove('foo');
}

/**
* @iterations 1000
*/
public function removeFastPriorityQueue()
public function benchRemoveFastPriorityQueue()
{
$this->fastPriorityQueue->remove('foo');
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"php": "^5.6 || ^7.0"
},
"require-dev": {
"athletic/athletic": "~0.1",
"phpbench/phpbench": "^0.13",
"phpunit/PHPUnit": "^5.7.21 || ^6.3",
"zendframework/zend-coding-standard": "~1.0.0"
},
Expand Down
Loading