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

Commit

Permalink
Merge branch 'feature/19' into develop
Browse files Browse the repository at this point in the history
Close #19
  • Loading branch information
weierophinney committed Sep 17, 2015
2 parents 297c699 + 24a59a6 commit 2e4f5db
Show file tree
Hide file tree
Showing 7 changed files with 595 additions and 4 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ All notable changes to this project will be documented in this file, in reverse

### Added

- Nothing.
- [#19](https://github.com/zendframework/zend-stdlib/pull/19) adds a new
`FastPriorityQueue` implementation. It follows the same signature as
`SplPriorityQueue`, but uses a performance-optimized algorithm:
- inserts are 2x faster than `SplPriorityQueue` and 3x faster than the
`Zend\Stdlib\PriorityQueue` implementation.
- extracts are 4x faster than `SplPriorityQueue` and 4-5x faster than the
`Zend\Stdlib\PriorityQueue` implementation.
The intention is to use this as a drop-in replacement in the
`zend-eventmanager` component to provide performance benefits.

### Deprecated

Expand Down
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ $ ./vendor/bin/php-cs-fixer fix . -v --diff --config-file=.php_cs
If you allow php-cs-fixer to fix CS issues, please re-run the tests to ensure
they pass, and make sure you add and commit the changes after verification.

## Benchmarks

We provide benchmark tests for zend-stdlib under the directory [benchmark/](benchmark/),
using. [athletic](https://github.com/polyfractal/athletic). You can execute
the benchmarks running the following command:

```bash
$ ./vendor/bin/athletic -p benchmark
```

## Recommended Workflow for Contributions

Your first step is to establish a public repository from which we can
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class for different scopes like:
- string wrappers;
- etc.

-
---

- File issues at https://github.com/zendframework/zend-stdlib/issues
- Documentation is at http://framework.zend.com/manual/current/en/index.html#zend-stdlib
80 changes: 80 additions & 0 deletions benchmark/PriorityQueueBenchmark.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace ZendBench\Stdlib;

use Athletic\AthleticEvent;
use Zend\Stdlib\FastPriorityQueue;
use Zend\Stdlib\PriorityQueue;
use Zend\Stdlib\SplPriorityQueue;

class PriorityQueueBenchmark extends AthleticEvent
{
public function classSetUp()
{
$this->splPriorityQueue = new SplPriorityQueue();
$this->fastPriorityQueue = new FastPriorityQueue();
$this->priorityQueue = new PriorityQueue();

for ($i = 0; $i < 5000; $i += 1) {
$priority = rand(1, 100);
$this->splPriorityQueue->insert('foo', $priority);
$this->fastPriorityQueue->insert('foo', $priority);
$this->priorityQueue->insert('foo', $priority);
}
}

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

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

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

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

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

/**
* @iterations 5000
*/
public function extractFastPriorityQueue()
{
$this->fastPriorityQueue->extract();
}
}
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"zendframework/zend-servicemanager": "~2.5",
"zendframework/zend-filter": "~2.5",
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/PHPUnit": "~4.0"
"phpunit/PHPUnit": "~4.0",
"athletic/athletic": "~0.1"
},
"suggest": {
"zendframework/zend-eventmanager": "To support aggregate hydrator usage",
Expand All @@ -41,7 +42,8 @@
},
"autoload-dev": {
"psr-4": {
"ZendTest\\Stdlib\\": "test/"
"ZendTest\\Stdlib\\": "test/",
"ZendBench\\Stdlib\\": "benchmark/"
}
}
}
Loading

0 comments on commit 2e4f5db

Please sign in to comment.