comparison vendor/zendframework/zend-stdlib/benchmark/ExtractPriorityQueue.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
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
10 namespace ZendBench\Stdlib;
11
12 use Athletic\AthleticEvent;
13 use Zend\Stdlib\FastPriorityQueue;
14 use Zend\Stdlib\PriorityQueue;
15 use Zend\Stdlib\SplPriorityQueue;
16
17 class ExtractPriorityQueue extends AthleticEvent
18 {
19 public function classSetUp()
20 {
21 $this->splPriorityQueue = new SplPriorityQueue();
22 $this->fastPriorityQueue = new FastPriorityQueue();
23 $this->priorityQueue = new PriorityQueue();
24
25 for ($i = 0; $i < 5000; $i += 1) {
26 $priority = rand(1, 100);
27 $this->splPriorityQueue->insert('foo', $priority);
28 $this->fastPriorityQueue->insert('foo', $priority);
29 $this->priorityQueue->insert('foo', $priority);
30 }
31 }
32
33 /**
34 * @iterations 5000
35 */
36 public function extractSplPriorityQueue()
37 {
38 $this->splPriorityQueue->extract();
39 }
40
41 /**
42 * @iterations 5000
43 */
44 public function extractPriorityQueue()
45 {
46 $this->priorityQueue->extract();
47 }
48
49 /**
50 * @iterations 5000
51 */
52 public function extractFastPriorityQueue()
53 {
54 $this->fastPriorityQueue->extract();
55 }
56 }