PageRenderTime 28ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/pizzafactory/pf-gcc
HTML | 162 lines | 161 code | 1 blank | 0 comment | 0 complexity | d146f2f669e226045368c1732186ee9b 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>Tree Text Find 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>Tree-Based and Trie-Based Text <tt>find</tt> Find Timing
  12. Test</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. a container, then performs a series of finds using
  17. <tt>find</tt>. It measures the average time for <tt>find</tt>
  18. as a function of the number of values inserted.</p>
  19. <p>(The test was executed with <a href="http://gcc.gnu.org/viewcvs/*checkout*/trunk/libstdc%2B%2B-v3/testsuite/performance/ext/pb_ds/text_find_timing.cc"><tt>text_find_timing_test</tt></a>
  20. thirty_years_among_the_dead_preproc.txt 200 200 2100)</p>
  21. <h2><a name="purpose" id="purpose">Purpose</a></h2>
  22. <p>The test checks the effect of different underlying
  23. data structures.</p>
  24. <h2><a name="results" id="results">Results</a></h2>
  25. <p>Figures <a href="#NTTG">NTTG</a>, <a href="#NTTM">NTTM</a>,
  26. and <a href="#NTTG">NTTL</a> show the results for the native,
  27. tree-based, and trie-based types in <a href="assoc_performance_tests.html#gcc"><u>g++</u></a>, <a href="assoc_performance_tests.html#local"><u>local</u></a>, and
  28. <a href="assoc_performance_tests.html#local"><u>local</u></a>,
  29. respectively.</p>
  30. <div id="NTTG_res_div">
  31. <div id="NTTG_gcc">
  32. <div id="NTTG_text_find_timing_test_tree_like">
  33. <div id="NTTG_assoc">
  34. <div id="NTTG_Native_456_tree-based_456_and_trie-based_456_text_find_timing_test_using__tt_find_455tt_"><div style="border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class="c1"><a name="NTTG" id="NTTG"><img src="text_find_timing_test_tree_like_gcc.png" alt="no image" /></a></h6>NTTG: Native, tree-based, and trie-based, text find timing test using <tt>find</tt> - <a href="assoc_performance_tests.html#gcc">g++</a><p>In the above figure, the names in the legends have the following meaning:</p>
  35. <ol>
  36. <li>
  37. splay_tree_map-
  38. <a href="tree.html"><tt>tree</tt></a>
  39. with <tt>Tag</tt> = <a href="splay_tree_tag.html"><tt>splay_tree_tag</tt></a>
  40. , and <tt>Node_Update</tt> = <a href="null_tree_node_update.html"><tt>null_tree_node_update</tt></a>
  41. </li>
  42. <li>
  43. ov_tree_map-
  44. <a href="tree.html"><tt>tree</tt></a>
  45. with <tt>Tag</tt> = <a href="ov_tree_tag.html"><tt>ov_tree_tag</tt></a>
  46. , and <tt>Node_Update</tt> = <a href="null_tree_node_update.html"><tt>null_tree_node_update</tt></a>
  47. </li>
  48. <li>
  49. rb_tree_map-
  50. <a href="tree.html"><tt>tree</tt></a>
  51. with <tt>Tag</tt> = <a href="rb_tree_tag.html"><tt>rb_tree_tag</tt></a>
  52. , and <tt>Node_Update</tt> = <a href="null_tree_node_update.html"><tt>null_tree_node_update</tt></a>
  53. </li>
  54. <li>
  55. n_map-
  56. <tt>std::map</tt></li>
  57. <li>
  58. pat_trie_map-
  59. <a href="trie.html"><tt>trie</tt></a>
  60. with <tt>Tag</tt> = <a href="pat_trie_tag.html"><tt>pat_trie_tag</tt></a>
  61. , and <tt>Node_Update</tt> = <a href="null_trie_node_update.html"><tt>null_trie_node_update</tt></a>
  62. </li>
  63. </ol>
  64. </div><div style="width: 100%; height: 20px"></div></div>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. <div id="NTTM_res_div">
  70. <div id="NTTM_msvc">
  71. <div id="NTTM_text_find_timing_test_tree_like">
  72. <div id="NTTM_assoc">
  73. <div id="NTTM_Native_456_tree-based_456_and_trie-based_456_text_find_timing_test_using__tt_find_455tt_"><div style="border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class="c1"><a name="NTTM" id="NTTM"><img src="text_find_timing_test_tree_like_msvc.png" alt="no image" /></a></h6>NTTM: Native, tree-based, and trie-based, text find timing test using <tt>find</tt> - <a href="assoc_performance_tests.html#msvc">msvc++</a><p>In the above figure, the names in the legends have the following meaning:</p>
  74. <ol>
  75. <li>
  76. splay_tree_map-
  77. <a href="tree.html"><tt>tree</tt></a>
  78. with <tt>Tag</tt> = <a href="splay_tree_tag.html"><tt>splay_tree_tag</tt></a>
  79. , and <tt>Node_Update</tt> = <a href="null_tree_node_update.html"><tt>null_tree_node_update</tt></a>
  80. </li>
  81. <li>
  82. ov_tree_map-
  83. <a href="tree.html"><tt>tree</tt></a>
  84. with <tt>Tag</tt> = <a href="ov_tree_tag.html"><tt>ov_tree_tag</tt></a>
  85. , and <tt>Node_Update</tt> = <a href="null_tree_node_update.html"><tt>null_tree_node_update</tt></a>
  86. </li>
  87. <li>
  88. rb_tree_map-
  89. <a href="tree.html"><tt>tree</tt></a>
  90. with <tt>Tag</tt> = <a href="rb_tree_tag.html"><tt>rb_tree_tag</tt></a>
  91. , and <tt>Node_Update</tt> = <a href="null_tree_node_update.html"><tt>null_tree_node_update</tt></a>
  92. </li>
  93. <li>
  94. n_map-
  95. <tt>std::map</tt></li>
  96. <li>
  97. pat_trie_map-
  98. <a href="trie.html"><tt>trie</tt></a>
  99. with <tt>Tag</tt> = <a href="pat_trie_tag.html"><tt>pat_trie_tag</tt></a>
  100. , and <tt>Node_Update</tt> = <a href="null_trie_node_update.html"><tt>null_trie_node_update</tt></a>
  101. </li>
  102. </ol>
  103. </div><div style="width: 100%; height: 20px"></div></div>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. <div id="NTTL_res_div">
  109. <div id="NTTL_local">
  110. <div id="NTTL_text_find_timing_test_tree_like">
  111. <div id="NTTL_assoc">
  112. <div id="NTTL_Native_456_tree-based_456_and_trie-based_456_text_find_timing_test_using__tt_find_455tt_"><div style = "border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class="c1"><a name="NTTL" id= "NTTL"><img src="text_find_timing_test_tree_like_local.png" alt="no image" /></a></h6>NTTL: Native, tree-based, and trie-based, text find timing test using <tt>find</tt> - <a href = "assoc_performance_tests.html#local">local</a></div><div style = "width: 100%; height: 20px"></div></div>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. <h2><a name="observations" id="observations">Observations</a></h2>
  118. <p>For this setting, a splay tree (<a href="tree.html"><tt>tree</tt></a>
  119. with <tt>Tag =</tt> <a href="splay_tree_tag.html"><tt>splay_tree_tag</tt></a>) does
  120. not do well. This is possibly due to two reasons:</p>
  121. <ol>
  122. <li>A splay tree is not guaranteed to be balanced [<a href="references.html#motwani95random">motwani95random</a>]. If a
  123. splay tree contains <i>n</i> nodes, its average root-leaf
  124. path can be <i>m &gt;&gt; log(n)</i>.</li>
  125. <li>Assume a specific root-leaf search path has length
  126. <i>m</i>, and the search-target node has distance <i>m'</i>
  127. from the root. A red-black tree will require <i>m + 1</i>
  128. comparisons to find the required node; a splay tree will
  129. require <i>2 m'</i> comparisons. A splay tree, consequently,
  130. can perform many more comparisons than a red-black tree.</li>
  131. </ol>
  132. <p>An ordered-vector tree (<a href="tree.html"><tt>tree</tt></a>
  133. with <tt>Tag =</tt> <a href="ov_tree_tag.html"><tt>ov_tree_tag</tt></a>), a red-black
  134. tree (<a href="tree.html"><tt>tree</tt></a>
  135. with <tt>Tag =</tt> <a href="splay_tree_tag.html"><tt>rb_tree_tag</tt></a>), and the
  136. native red-black tree all share approximately the same
  137. performance.</p>
  138. <p>An ordered-vector tree is slightly slower than red-black
  139. trees, since it requires, in order to find a key, more math
  140. operations than they do. Conversely, an ordered-vector tree
  141. requires far lower space than the others. ([<a href="references.html#austern00noset">austern00noset</a>], however,
  142. seems to have an implementation that is also faster than a
  143. red-black tree).</p>
  144. <p>A PATRICIA trie (<a href="trie.html"><tt>trie</tt></a>
  145. with <tt>Tag =</tt> <a href="pat_trie_tag.html"><tt>pat_trie_tag</tt></a>) has good
  146. look-up performance, due to its large fan-out in this case. In
  147. this setting, a PATRICIA trie has look-up performance comparable
  148. to a hash table (see <a href="hash_text_find_find_timing_test.html">Hash-Based Text
  149. <tt>find</tt> Find Timing Test</a>), but it is order
  150. preserving. This is not that surprising, since a large-fan-out
  151. PATRICIA trie works like a hash table with collisions resolved
  152. by a sub-trie. A large-fan-out PATRICIA trie does not do well on
  153. modifications (see <a href="tree_text_insert_timing_test.html">Tree-Based and Trie-Based
  154. Text Insert Timing Test</a>). It is possibly beneficial to
  155. semi-static settings, therefore.</p>
  156. <p><a href="assoc_performance_tests.html#tree_like_based_types">Observations::Tree-Like-Based
  157. Container Types</a> summarizes some observations on tree-based
  158. and trie-based containers.</p>
  159. </div>
  160. </body>
  161. </html>