1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6 <meta name="generator" content="HTML Tidy for Linux/x86 (vers 12 April 2005), see www.w3.org" />
7 <title>Priority Queue Random Int Push Pop Timing Test</title>
8 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
12 <h1>Priority Queue Random Integer <tt>push</tt> and
13 <tt>pop</tt> Timing Test</h1>
14 <h2><a name="description" id="description">Description</a></h2>
15 <p>This test inserts a number of values with i.i.d. integer
16 keys into a container using <tt>push</tt> , then removes them
17 using <tt>pop</tt> . It measures the average time for
18 <tt>push</tt> and <tt>pop</tt> as a function of the number of
20 <p>(The test was executed with <a href="../../../../testsuite/performance/ext/pb_ds/priority_queue_random_int_push_pop_timing.cc">
21 <tt>priority_queue_random_int_push_pop_timing_test</tt></a>
22 thirty_years_among_the_dead_preproc.txt 200 200 2100)</p>
23 <h2><a name="purpose" id="purpose">Purpose</a></h2>
24 <p>The test checks the effect of different underlying
25 data structures (see <a href="pq_design.html#pq_imp">Design::Priority
26 Queues::Implementations</a>).</p>
27 <h2><a name="results" id="results">Results</a></h2>
28 <p>Figures <a href="#NPG">NPG</a>, <a href="#NPM">NPM</a>, and
29 <a href="#NPL">NPL</a> shows the results for the native
30 priority queues and <tt>pb_ds</tt> 's priority queues in
31 <a href="pq_performance_tests.html#gcc"><u>g++</u></a>,
32 <a href="pq_performance_tests.html#msvc"><u>msvc++</u></a>, and
33 <a href="pq_performance_tests.html#local"><u>local</u></a>,
35 <div id="NPG_res_div">
37 <div id="NPG_priority_queue_random_int_push_pop_timing_test">
39 <div id="NPG_Native_and__tt_pb_ds_455tt__priority_queue__tt_push_455tt___tt_pop_455tt__timing_test"><div style="border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class="c1"><a name="NPG" id="NPG"><img src="priority_queue_random_int_push_pop_timing_test_gcc.png" alt="no image" /></a></h6>NPG: Native and <tt>pb ds</tt> priority queue <tt>push</tt> <tt>pop</tt> timing test - <a href="pq_performance_tests.html#gcc">g++</a><p>In the above figure, the names in the legends have the following meaning:</p>
43 <a href="priority_queue.html"><tt>priority_queue</tt></a>
44 with <tt>Tag</tt> = <a href="thin_heap_tag.html"><tt>thin_heap_tag</tt></a>
48 <a href="priority_queue.html"><tt>priority_queue</tt></a>
49 with <tt>Tag</tt> = <a href="rc_binomial_heap_tag.html"><tt>rc_binomial_heap_tag</tt></a>
53 <a href="priority_queue.html"><tt>priority_queue</tt></a>
54 with <tt>Tag</tt> = <a href="binomial_heap_tag.html"><tt>binomial_heap_tag</tt></a>
58 <a href="priority_queue.html"><tt>priority_queue</tt></a>
59 with <tt>Tag</tt> = <a href="pairing_heap_tag.html"><tt>pairing_heap_tag</tt></a>
63 <tt>std::priority_queue</tt> adapting <tt>std::deque</tt></li>
66 <tt>std::priority_queue</tt> adapting <tt>std::vector</tt></li>
69 <a href="priority_queue.html"><tt>priority_queue</tt></a>
70 with <tt>Tag</tt> = <a href="binary_heap_tag.html"><tt>binary_heap_tag</tt></a>
73 </div><div style="width: 100%; height: 20px"></div></div>
78 <div id="NPM_res_div">
80 <div id="NPM_priority_queue_random_int_push_pop_timing_test">
82 <div id="NPM_Native_and__tt_pb_ds_455tt__priority_queue__tt_push_455tt___tt_pop_455tt__timing_test"><div style="border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class="c1"><a name="NPM" id="NPM"><img src="priority_queue_random_int_push_pop_timing_test_msvc.png" alt="no image" /></a></h6>NPM: Native and <tt>pb ds</tt> priority queue <tt>push</tt> <tt>pop</tt> timing test - <a href="pq_performance_tests.html#msvc">msvc++</a><p>In the above figure, the names in the legends have the following meaning:</p>
86 <a href="priority_queue.html"><tt>priority_queue</tt></a>
87 with <tt>Tag</tt> = <a href="thin_heap_tag.html"><tt>thin_heap_tag</tt></a>
91 <a href="priority_queue.html"><tt>priority_queue</tt></a>
92 with <tt>Tag</tt> = <a href="rc_binomial_heap_tag.html"><tt>rc_binomial_heap_tag</tt></a>
96 <a href="priority_queue.html"><tt>priority_queue</tt></a>
97 with <tt>Tag</tt> = <a href="binomial_heap_tag.html"><tt>binomial_heap_tag</tt></a>
101 <a href="priority_queue.html"><tt>priority_queue</tt></a>
102 with <tt>Tag</tt> = <a href="pairing_heap_tag.html"><tt>pairing_heap_tag</tt></a>
106 <tt>std::priority_queue</tt> adapting <tt>std::deque</tt></li>
109 <tt>std::priority_queue</tt> adapting <tt>std::vector</tt></li>
112 <a href="priority_queue.html"><tt>priority_queue</tt></a>
113 with <tt>Tag</tt> = <a href="binary_heap_tag.html"><tt>binary_heap_tag</tt></a>
116 </div><div style="width: 100%; height: 20px"></div></div>
121 <div id="NPL_res_div">
123 <div id="NPL_priority_queue_random_int_push_pop_timing_test">
125 <div id="NPL_Native_and__tt_pb_ds_455tt__priority_queue__tt_push_455tt___tt_pop_455tt__timing_test"><div style = "border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class="c1"><a name="NPL" id= "NPL"><img src="priority_queue_random_int_push_pop_timing_test_local.png" alt="no image" /></a></h6>NPL: Native and <tt>pb ds</tt> priority queue <tt>push</tt> <tt>pop</tt> timing test - <a href = "pq_performance_tests.html#local">local</a></div><div style = "width: 100%; height: 20px"></div></div>
130 <h2><a name="observations" id="observations">Observations</a></h2>
131 <p>Binary heaps are the most suited for sequences of
132 <tt>push</tt> and <tt>pop</tt> operations of primitive types
133 (<i>e.g.</i> <tt><b>int</b></tt>s). This is explained in
134 <a href="priority_queue_random_int_push_timing_test.html">Priority
135 Queue Random Int <tt>push</tt> Timing Test</a> . (See <a href="priority_queue_text_push_pop_timing_test.html">Priority Queue
136 Text <tt>push</tt> Timing Test</a> for the case of primitive
138 <p>At first glance it seems that the STL's vector-based
139 priority queue is approximately on par with <tt>pb_ds</tt>'s
140 corresponding priority queue. There are two differences
143 <li>The STL's priority queue does not downsize the underlying
144 vector (or deque) as the priority queue becomes smaller
145 (see <a href="priority_queue_text_pop_mem_usage_test.html">Priority Queue
146 Text <tt>pop</tt> Memory Use Test</a>). It is therefore
147 gaining some speed at the expense of space.</li>
148 <li>From <a href="priority_queue_random_int_push_pop_timing_test.html">Priority
149 Queue Random Integer <tt>push</tt> and <tt>pop</tt> Timing
150 Test</a>, it seems that the STL's priority queue is slower in
151 terms of <tt>pus</tt> operations. Since the number of
152 <tt>pop</tt> operations is at most that of <tt>push</tt>
153 operations, the test here is the "best" for the STL's
156 <p><a href="pq_performance_tests.html#pq_observations">Priority-Queue
157 Performance Tests::Observations</a> discusses this further and