PageRenderTime 25ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/libstdc++-v3/doc/html/ext/pb_ds/priority_queue_text_modify_up_timing_test.html

https://bitbucket.org/pizzafactory/pf-gcc
HTML | 222 lines | 221 code | 1 blank | 0 comment | 0 complexity | 1a12a393251439f9cdc28e443fef8c2b MD5 | raw file
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <meta name="generator" content="HTML Tidy for Linux/x86 (vers 12 April 2005), see www.w3.org" />
  6. <title>Priority Queue Text Modify (Up) Timing Test</title>
  7. <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
  8. </head>
  9. <body>
  10. <div id="page">
  11. <h1>Priority Queue Text <tt>modify</tt> Timing Test - I</h1>
  12. <h2><a name="description" id="description">Description</a></h2>
  13. <p>This test inserts a number of values with keys from an
  14. arbitrary text ([ <a href="references.html#wickland96thirty">wickland96thirty</a> ]) into
  15. into a container then modifies each one "up" (<i>i.e.,</i> it
  16. makes it larger). It uses <tt>modify</tt> for <tt>pb_ds</tt>'s
  17. priority queues; for the STL's priority queues, it pops values
  18. from a container until it reaches the value that should be
  19. modified, then pushes values back in. It measures the average
  20. time for <tt>modify</tt> as a function of the number of
  21. values.</p>
  22. <p>(The test was executed with <a href="http://gcc.gnu.org/viewcvs/*checkout*/trunk/libstdc%2B%2B-v3/testsuite/performance/ext/pb_ds/priority_queue_text_modify_timing.cc"><tt>priority_queue_text_modify_up_timing_test</tt></a>
  23. thirty_years_among_the_dead_preproc.txt 200 200 2100 t)</p>
  24. <h2><a name="purpose" id="purpose">Purpose</a></h2>
  25. <p>The test checks the effect of different underlying
  26. data structures (see <a href="pq_design.html#pq_imp">Design::Priority
  27. Queues::Implementations</a>) for graph algorithms settings.
  28. Note that making an arbitrary value larger (in the sense of the
  29. priority queue's comparison functor) corresponds to
  30. decrease-key in standard graph algorithms [<a href="references.html#clrs2001">clrs2001</a>].</p>
  31. <h2><a name="results" id="results">Results</a></h2>
  32. <p>Figures <a href="#NPG">NPG</a>, <a href="#NPM">NPM</a>, and
  33. <a href="#NPL">NPL</a> show the results for the native priority
  34. 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
  35. <a href="pq_performance_tests.html#local"><u>local</u></a>,
  36. respectively; Figures <a href="#NRTG">NRTG</a>, <a href="#NRTM">NRTM</a>, and <a href="#NRTL">NRTL</a> show the results
  37. 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
  38. <a href="pq_performance_tests.html#local"><u>local</u></a>,
  39. respectively,</p>
  40. <div id="NPG_res_div">
  41. <div id="NPG_gcc">
  42. <div id="NPG_priority_queue_text_modify_up_timing_test">
  43. <div id="NPG_pq">
  44. <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>
  45. <ol>
  46. <li>
  47. n_pq_deque-
  48. <tt>std::priority_queue</tt> adapting <tt>std::deque</tt></li>
  49. <li>
  50. n_pq_vector-
  51. <tt>std::priority_queue</tt> adapting <tt>std::vector</tt></li>
  52. <li>
  53. binary_heap-
  54. <a href="priority_queue.html"><tt>priority_queue</tt></a>
  55. with <tt>Tag</tt> = <a href="binary_heap_tag.html"><tt>binary_heap_tag</tt></a>
  56. </li>
  57. <li>
  58. rc_binomial_heap-
  59. <a href="priority_queue.html"><tt>priority_queue</tt></a>
  60. with <tt>Tag</tt> = <a href="rc_binomial_heap_tag.html"><tt>rc_binomial_heap_tag</tt></a>
  61. </li>
  62. <li>
  63. pairing_heap-
  64. <a href="priority_queue.html"><tt>priority_queue</tt></a>
  65. with <tt>Tag</tt> = <a href="pairing_heap_tag.html"><tt>pairing_heap_tag</tt></a>
  66. </li>
  67. <li>
  68. binomial_heap-
  69. <a href="priority_queue.html"><tt>priority_queue</tt></a>
  70. with <tt>Tag</tt> = <a href="binomial_heap_tag.html"><tt>binomial_heap_tag</tt></a>
  71. </li>
  72. <li>
  73. thin_heap-
  74. <a href="priority_queue.html"><tt>priority_queue</tt></a>
  75. with <tt>Tag</tt> = <a href="thin_heap_tag.html"><tt>thin_heap_tag</tt></a>
  76. </li>
  77. </ol>
  78. </div><div style="width: 100%; height: 20px"></div></div>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. <div id="NPM_res_div">
  84. <div id="NPM_msvc">
  85. <div id="NPM_priority_queue_text_modify_up_timing_test">
  86. <div id="NPM_pq">
  87. <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>
  88. <ol>
  89. <li>
  90. n_pq_deque-
  91. <tt>std::priority_queue</tt> adapting <tt>std::deque</tt></li>
  92. <li>
  93. n_pq_vector-
  94. <tt>std::priority_queue</tt> adapting <tt>std::vector</tt></li>
  95. <li>
  96. binary_heap-
  97. <a href="priority_queue.html"><tt>priority_queue</tt></a>
  98. with <tt>Tag</tt> = <a href="binary_heap_tag.html"><tt>binary_heap_tag</tt></a>
  99. </li>
  100. <li>
  101. rc_binomial_heap-
  102. <a href="priority_queue.html"><tt>priority_queue</tt></a>
  103. with <tt>Tag</tt> = <a href="rc_binomial_heap_tag.html"><tt>rc_binomial_heap_tag</tt></a>
  104. </li>
  105. <li>
  106. pairing_heap-
  107. <a href="priority_queue.html"><tt>priority_queue</tt></a>
  108. with <tt>Tag</tt> = <a href="pairing_heap_tag.html"><tt>pairing_heap_tag</tt></a>
  109. </li>
  110. <li>
  111. binomial_heap-
  112. <a href="priority_queue.html"><tt>priority_queue</tt></a>
  113. with <tt>Tag</tt> = <a href="binomial_heap_tag.html"><tt>binomial_heap_tag</tt></a>
  114. </li>
  115. <li>
  116. thin_heap-
  117. <a href="priority_queue.html"><tt>priority_queue</tt></a>
  118. with <tt>Tag</tt> = <a href="thin_heap_tag.html"><tt>thin_heap_tag</tt></a>
  119. </li>
  120. </ol>
  121. </div><div style="width: 100%; height: 20px"></div></div>
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. <div id="NPL_res_div">
  127. <div id="NPL_local">
  128. <div id="NPL_priority_queue_text_modify_up_timing_test">
  129. <div id="NPL_pq">
  130. <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>
  131. </div>
  132. </div>
  133. </div>
  134. </div>
  135. <div id="NRTG_res_div">
  136. <div id="NRTG_gcc">
  137. <div id="NRTG_priority_queue_text_modify_up_timing_test_pairing_thin">
  138. <div id="NRTG_pq">
  139. <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>
  140. <ol>
  141. <li>
  142. pairing_heap-
  143. <a href="priority_queue.html"><tt>priority_queue</tt></a>
  144. with <tt>Tag</tt> = <a href="pairing_heap_tag.html"><tt>pairing_heap_tag</tt></a>
  145. </li>
  146. <li>
  147. thin_heap-
  148. <a href="priority_queue.html"><tt>priority_queue</tt></a>
  149. with <tt>Tag</tt> = <a href="thin_heap_tag.html"><tt>thin_heap_tag</tt></a>
  150. </li>
  151. </ol>
  152. </div><div style="width: 100%; height: 20px"></div></div>
  153. </div>
  154. </div>
  155. </div>
  156. </div>
  157. <div id="NRTM_res_div">
  158. <div id="NRTM_msvc">
  159. <div id="NRTM_priority_queue_text_modify_up_timing_test_pairing_thin">
  160. <div id="NRTM_pq">
  161. <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>
  162. <ol>
  163. <li>
  164. pairing_heap-
  165. <a href="priority_queue.html"><tt>priority_queue</tt></a>
  166. with <tt>Tag</tt> = <a href="pairing_heap_tag.html"><tt>pairing_heap_tag</tt></a>
  167. </li>
  168. <li>
  169. thin_heap-
  170. <a href="priority_queue.html"><tt>priority_queue</tt></a>
  171. with <tt>Tag</tt> = <a href="thin_heap_tag.html"><tt>thin_heap_tag</tt></a>
  172. </li>
  173. </ol>
  174. </div><div style="width: 100%; height: 20px"></div></div>
  175. </div>
  176. </div>
  177. </div>
  178. </div>
  179. <div id="NRTL_res_div">
  180. <div id="NRTL_local">
  181. <div id="NRTL_priority_queue_text_modify_up_timing_test_pairing_thin">
  182. <div id="NRTL_pq">
  183. <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>
  184. </div>
  185. </div>
  186. </div>
  187. </div>
  188. <h2><a name="observations" id="observations">Observations</a></h2>
  189. <p>As noted above, increasing an arbitrary value (in the sense
  190. of the priority queue's comparison functor) is very common in
  191. graph-related algorithms. In this case, a thin heap (<a href="priority_queue.html"><tt>priority_queue</tt></a> with
  192. <tt>Tag</tt> = <a href="thin_heap_tag.html"><tt>thin_heap_tag</tt></a>)
  193. outperforms a pairing heap (<a href="priority_queue.html"><tt>priority_queue</tt></a> with
  194. <tt>Tag</tt> = <a href="pairing_heap_tag.html"><tt>pairing_heap_tag</tt></a>).
  195. Conversely, <a href="priority_queue_text_push_timing_test.html">Priority Queue Text
  196. <tt>push</tt> Timing Test</a>, <a href="priority_queue_text_push_pop_timing_test.html">Priority Queue
  197. Text <tt>push</tt> and <tt>pop</tt> Timing Test</a>, <a href="priority_queue_random_int_push_timing_test.html">Priority
  198. Queue Random Integer <tt>push</tt> Timing Test</a>, and
  199. <a href="priority_queue_random_int_push_pop_timing_test.html">Priority
  200. Queue Random Integer <tt>push</tt> and <tt>pop</tt> Timing
  201. Test</a> show that the situation is reversed for other
  202. operations. It is not clear when to prefer one of these two
  203. different types.</p>
  204. <p>In this test <tt>pb_ds</tt>'s binary heaps effectively
  205. perform modify in linear time. As explained in <a href="pq_design.html#pq_traits">Priority Queue Design::Traits</a>,
  206. given a valid point-type iterator, a binary heap can perform
  207. <tt>modify</tt> logarithmically. The problem is that binary
  208. heaps invalidate their find iterators with each modifying
  209. operation, and so the only way to obtain a valid point-type
  210. iterator is to iterate using a range-type iterator until
  211. finding the appropriate value, then use the range-type iterator
  212. for the <tt>modify</tt> operation.</p>
  213. <p>The explanation for the STL's priority queues' performance
  214. is similar to that in <a href="priority_queue_text_join_timing_test.html">Priority Queue Text
  215. <tt>join</tt> Timing Test</a>.</p>
  216. <p><a href="pq_performance_tests.html#pq_observations">Priority-Queue
  217. Performance Tests::Observations</a> discusses this further and
  218. summarizes.</p>
  219. </div>
  220. </body>
  221. </html>