InsertPriorityQueue.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. use Zend\Stdlib\SplPriorityQueue;
  14. class InsertPriorityQueue extends AthleticEvent
  15. {
  16. public function classSetUp()
  17. {
  18. $this->splPriorityQueue = new SplPriorityQueue();
  19. $this->fastPriorityQueue = new FastPriorityQueue();
  20. $this->priorityQueue = new PriorityQueue();
  21. }
  22. /**
  23. * @iterations 5000
  24. */
  25. public function insertSplPriorityQueue()
  26. {
  27. $this->splPriorityQueue->insert('foo', rand(1, 100));
  28. }
  29. /**
  30. * @iterations 5000
  31. */
  32. public function insertPriorityQueue()
  33. {
  34. $this->priorityQueue->insert('foo', rand(1, 100));
  35. }
  36. /**
  37. * @iterations 5000
  38. */
  39. public function insertFastPriorityQueue()
  40. {
  41. $this->fastPriorityQueue->insert('foo', rand(1, 100));
  42. }
  43. }