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 Text Modify (Up) Timing Test
</title>
8 <meta http-equiv=
"Content-Type" content=
"text/html; charset=us-ascii" />
12 <h1>Priority Queue Text
<tt>modify
</tt> Timing Test - I
</h1>
13 <h2><a name=
"description" id=
"description">Description
</a></h2>
14 <p>This test inserts a number of values with keys from an
15 arbitrary text ([
<a href=
"references.html#wickland96thirty">wickland96thirty
</a> ]) into
16 into a container then modifies each one
"up" (
<i>i.e.,
</i> it
17 makes it larger). It uses
<tt>modify
</tt> for
<tt>pb_ds
</tt>'s
18 priority queues; for the STL's priority queues, it pops values
19 from a container until it reaches the value that should be
20 modified, then pushes values back in. It measures the average
21 time for
<tt>modify
</tt> as a function of the number of
23 <p>(The test was executed with
<a href=
"../../../../testsuite/performance/ext/pb_ds/priority_queue_text_modify_timing.cc"><tt>priority_queue_text_modify_up_timing_test
</tt></a>
24 thirty_years_among_the_dead_preproc.txt
200 200 2100 t)
</p>
25 <h2><a name=
"purpose" id=
"purpose">Purpose
</a></h2>
26 <p>The test checks the effect of different underlying
27 data structures (see
<a href=
"pq_design.html#pq_imp">Design::Priority
28 Queues::Implementations
</a>) for graph algorithms settings.
29 Note that making an arbitrary value larger (in the sense of the
30 priority queue's comparison functor) corresponds to
31 decrease-key in standard graph algorithms [
<a href=
"references.html#clrs2001">clrs2001
</a>].
</p>
32 <h2><a name=
"results" id=
"results">Results
</a></h2>
33 <p>Figures
<a href=
"#NPG">NPG
</a>,
<a href=
"#NPM">NPM
</a>, and
34 <a href=
"#NPL">NPL
</a> show the results for the native priority
35 queues and
<tt>pb_ds
</tt> 's priority queues in
<a href=
"pq_performance_tests.html#gcc"><u>g++
</u></a>,
<a href=
"pq_performance_tests.html#msvc"><u>msvc++
</u></a>, and
36 <a href=
"pq_performance_tests.html#local"><u>local
</u></a>,
37 respectively; Figures
<a href=
"#NRTG">NRTG
</a>,
<a href=
"#NRTM">NRTM
</a>, and
<a href=
"#NRTL">NRTL
</a> show the results
38 for the pairing heap and thin heaps in
<a href=
"pq_performance_tests.html#gcc"><u>g++
</u></a>,
<a href=
"pq_performance_tests.html#msvc"><u>msvc++
</u></a>, and
39 <a href=
"pq_performance_tests.html#local"><u>local
</u></a>,
41 <div id=
"NPG_res_div">
43 <div id=
"NPG_priority_queue_text_modify_up_timing_test">
45 <div id=
"NPG_Native_and__tt_pb_ds_455tt__priority_queue__tt_modify_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_text_modify_up_timing_test_gcc.png" alt=
"no image" /></a></h6>NPG: Native and
<tt>pb ds
</tt> priority queue
<tt>modify
</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>
49 <tt>std::priority_queue
</tt> adapting
<tt>std::deque
</tt></li>
52 <tt>std::priority_queue
</tt> adapting
<tt>std::vector
</tt></li>
55 <a href=
"priority_queue.html"><tt>priority_queue
</tt></a>
56 with
<tt>Tag
</tt> =
<a href=
"binary_heap_tag.html"><tt>binary_heap_tag
</tt></a>
60 <a href=
"priority_queue.html"><tt>priority_queue
</tt></a>
61 with
<tt>Tag
</tt> =
<a href=
"rc_binomial_heap_tag.html"><tt>rc_binomial_heap_tag
</tt></a>
65 <a href=
"priority_queue.html"><tt>priority_queue
</tt></a>
66 with
<tt>Tag
</tt> =
<a href=
"pairing_heap_tag.html"><tt>pairing_heap_tag
</tt></a>
70 <a href=
"priority_queue.html"><tt>priority_queue
</tt></a>
71 with
<tt>Tag
</tt> =
<a href=
"binomial_heap_tag.html"><tt>binomial_heap_tag
</tt></a>
75 <a href=
"priority_queue.html"><tt>priority_queue
</tt></a>
76 with
<tt>Tag
</tt> =
<a href=
"thin_heap_tag.html"><tt>thin_heap_tag
</tt></a>
79 </div><div style=
"width: 100%; height: 20px"></div></div>
84 <div id=
"NPM_res_div">
86 <div id=
"NPM_priority_queue_text_modify_up_timing_test">
88 <div id=
"NPM_Native_and__tt_pb_ds_455tt__priority_queue__tt_modify_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_text_modify_up_timing_test_msvc.png" alt=
"no image" /></a></h6>NPM: Native and
<tt>pb ds
</tt> priority queue
<tt>modify
</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>
92 <tt>std::priority_queue
</tt> adapting
<tt>std::deque
</tt></li>
95 <tt>std::priority_queue
</tt> adapting
<tt>std::vector
</tt></li>
98 <a href=
"priority_queue.html"><tt>priority_queue
</tt></a>
99 with
<tt>Tag
</tt> =
<a href=
"binary_heap_tag.html"><tt>binary_heap_tag
</tt></a>
103 <a href=
"priority_queue.html"><tt>priority_queue
</tt></a>
104 with
<tt>Tag
</tt> =
<a href=
"rc_binomial_heap_tag.html"><tt>rc_binomial_heap_tag
</tt></a>
108 <a href=
"priority_queue.html"><tt>priority_queue
</tt></a>
109 with
<tt>Tag
</tt> =
<a href=
"pairing_heap_tag.html"><tt>pairing_heap_tag
</tt></a>
113 <a href=
"priority_queue.html"><tt>priority_queue
</tt></a>
114 with
<tt>Tag
</tt> =
<a href=
"binomial_heap_tag.html"><tt>binomial_heap_tag
</tt></a>
118 <a href=
"priority_queue.html"><tt>priority_queue
</tt></a>
119 with
<tt>Tag
</tt> =
<a href=
"thin_heap_tag.html"><tt>thin_heap_tag
</tt></a>
122 </div><div style=
"width: 100%; height: 20px"></div></div>
127 <div id=
"NPL_res_div">
129 <div id=
"NPL_priority_queue_text_modify_up_timing_test">
131 <div id=
"NPL_Native_and__tt_pb_ds_455tt__priority_queue__tt_modify_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_text_modify_up_timing_test_local.png" alt=
"no image" /></a></h6>NPL: Native and
<tt>pb ds
</tt> priority queue
<tt>modify
</tt> timing test -
<a href =
"pq_performance_tests.html#local">local
</a></div><div style =
"width: 100%; height: 20px"></div></div>
136 <div id=
"NRTG_res_div">
138 <div id=
"NRTG_priority_queue_text_modify_up_timing_test_pairing_thin">
140 <div id=
"NRTG_Pairing_and_thin__priority_queue__tt_modify_455tt__timing_test"><div style=
"border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class=
"c1"><a name=
"NRTG" id=
"NRTG"><img src=
"priority_queue_text_modify_up_timing_test_pairing_thin_gcc.png" alt=
"no image" /></a></h6>NRTG: Pairing and thin priority queue
<tt>modify
</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>
144 <a href=
"priority_queue.html"><tt>priority_queue
</tt></a>
145 with
<tt>Tag
</tt> =
<a href=
"pairing_heap_tag.html"><tt>pairing_heap_tag
</tt></a>
149 <a href=
"priority_queue.html"><tt>priority_queue
</tt></a>
150 with
<tt>Tag
</tt> =
<a href=
"thin_heap_tag.html"><tt>thin_heap_tag
</tt></a>
153 </div><div style=
"width: 100%; height: 20px"></div></div>
158 <div id=
"NRTM_res_div">
160 <div id=
"NRTM_priority_queue_text_modify_up_timing_test_pairing_thin">
162 <div id=
"NRTM_Pairing_and_thin__priority_queue__tt_modify_455tt__timing_test"><div style=
"border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class=
"c1"><a name=
"NRTM" id=
"NRTM"><img src=
"priority_queue_text_modify_up_timing_test_pairing_thin_msvc.png" alt=
"no image" /></a></h6>NRTM: Pairing and thin priority queue
<tt>modify
</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>
166 <a href=
"priority_queue.html"><tt>priority_queue
</tt></a>
167 with
<tt>Tag
</tt> =
<a href=
"pairing_heap_tag.html"><tt>pairing_heap_tag
</tt></a>
171 <a href=
"priority_queue.html"><tt>priority_queue
</tt></a>
172 with
<tt>Tag
</tt> =
<a href=
"thin_heap_tag.html"><tt>thin_heap_tag
</tt></a>
175 </div><div style=
"width: 100%; height: 20px"></div></div>
180 <div id=
"NRTL_res_div">
181 <div id=
"NRTL_local">
182 <div id=
"NRTL_priority_queue_text_modify_up_timing_test_pairing_thin">
184 <div id=
"NRTL_Pairing_and_thin__priority_queue__tt_modify_455tt__timing_test"><div style =
"border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class=
"c1"><a name=
"NRTL" id=
"NRTL"><img src=
"priority_queue_text_modify_up_timing_test_pairing_thin_local.png" alt=
"no image" /></a></h6>NRTL: Pairing and thin priority queue
<tt>modify
</tt> timing test -
<a href =
"pq_performance_tests.html#local">local
</a></div><div style =
"width: 100%; height: 20px"></div></div>
189 <h2><a name=
"observations" id=
"observations">Observations
</a></h2>
190 <p>As noted above, increasing an arbitrary value (in the sense
191 of the priority queue's comparison functor) is very common in
192 graph-related algorithms. In this case, a thin heap (
<a href=
"priority_queue.html"><tt>priority_queue
</tt></a> with
193 <tt>Tag
</tt> =
<a href=
"thin_heap_tag.html"><tt>thin_heap_tag
</tt></a>)
194 outperforms a pairing heap (
<a href=
"priority_queue.html"><tt>priority_queue
</tt></a> with
195 <tt>Tag
</tt> =
<a href=
"pairing_heap_tag.html"><tt>pairing_heap_tag
</tt></a>).
196 Conversely,
<a href=
"priority_queue_text_push_timing_test.html">Priority Queue Text
197 <tt>push
</tt> Timing Test
</a>,
<a href=
"priority_queue_text_push_pop_timing_test.html">Priority Queue
198 Text
<tt>push
</tt> and
<tt>pop
</tt> Timing Test
</a>,
<a href=
"priority_queue_random_int_push_timing_test.html">Priority
199 Queue Random Integer
<tt>push
</tt> Timing Test
</a>, and
200 <a href=
"priority_queue_random_int_push_pop_timing_test.html">Priority
201 Queue Random Integer
<tt>push
</tt> and
<tt>pop
</tt> Timing
202 Test
</a> show that the situation is reversed for other
203 operations. It is not clear when to prefer one of these two
205 <p>In this test
<tt>pb_ds
</tt>'s binary heaps effectively
206 perform modify in linear time. As explained in
<a href=
"pq_design.html#pq_traits">Priority Queue Design::Traits
</a>,
207 given a valid point-type iterator, a binary heap can perform
208 <tt>modify
</tt> logarithmically. The problem is that binary
209 heaps invalidate their find iterators with each modifying
210 operation, and so the only way to obtain a valid point-type
211 iterator is to iterate using a range-type iterator until
212 finding the appropriate value, then use the range-type iterator
213 for the
<tt>modify
</tt> operation.
</p>
214 <p>The explanation for the STL's priority queues' performance
215 is similar to that in
<a href=
"priority_queue_text_join_timing_test.html">Priority Queue Text
216 <tt>join
</tt> Timing Test
</a>.
</p>
217 <p><a href=
"pq_performance_tests.html#pq_observations">Priority-Queue
218 Performance Tests::Observations
</a> discusses this further and