Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Switching to phpbench/phpbench based benchmarks #79

Merged
merged 5 commits into from
Oct 24, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Switching to phpbench/phpbench based benchmarks
  • Loading branch information
michalbundyra committed Oct 24, 2017
commit 808cdbcbee0e66d3bb8d065b0b34ceedc6436328
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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ matrix:
env:
- DEPS=locked
- CS_CHECK=true
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable was wrong!! Please see line 71/73.

Yeah, I know... the best if we have it in separate PR...

- BENCHMARKS=true
- TEST_COVERAGE=true
- php: 7
env:
Expand Down Expand Up @@ -67,11 +68,11 @@ install:

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