This repository has been archived by the owner on Jan 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from ezimuel/feature/fastpriorityqueue
Added the FastPriorityQueue implementation
- Loading branch information
Showing
5 changed files
with
562 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
namespace ZendBench\Stdlib; | ||
|
||
use Athletic\AthleticEvent; | ||
|
||
class PriorityQueue extends AthleticEvent | ||
{ | ||
public function classSetUp() | ||
{ | ||
$this->splPriorityQueue = new \Zend\Stdlib\SplPriorityQueue(); | ||
$this->fastPriorityQueue = new \Zend\Stdlib\FastPriorityQueue(); | ||
$this->priorityQueue = new \Zend\Stdlib\PriorityQueue(); | ||
|
||
for($i=0; $i<5000; $i++) { | ||
$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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.