RemovePriorityQueue.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Zend Framework (http://framework.zend.com/)
  4. *
  5. * @link http://github.com/zendframework/zf2 for the canonical source repository
  6. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  7. * @license http://framework.zend.com/license/new-bsd New BSD License
  8. */
  9. namespace ZendBench\Stdlib;
  10. use Athletic\AthleticEvent;
  11. use Zend\Stdlib\FastPriorityQueue;
  12. use Zend\Stdlib\PriorityQueue;
  13. class RemovePriorityQueue extends AthleticEvent
  14. {
  15. public function classSetUp()
  16. {
  17. $this->fastPriorityQueue = new FastPriorityQueue();
  18. $this->priorityQueue = new PriorityQueue();
  19. for ($i = 0; $i < 1000; $i += 1) {
  20. $priority = rand(1, 100);
  21. $this->fastPriorityQueue->insert('foo', $priority);
  22. $this->priorityQueue->insert('foo', $priority);
  23. }
  24. }
  25. /**
  26. * @iterations 1000
  27. */
  28. public function removePriorityQueue()
  29. {
  30. $this->priorityQueue->remove('foo');
  31. }
  32. /**
  33. * @iterations 1000
  34. */
  35. public function removeFastPriorityQueue()
  36. {
  37. $this->fastPriorityQueue->remove('foo');
  38. }
  39. }