PageRenderTime 34ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/pizzafactory/pf-gcc
HTML | 143 lines | 142 code | 1 blank | 0 comment | 0 complexity | 822f7e835290cce8a533333f10287d03 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 Split Join 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 Split-Join Timing Test</h1>
  12. <h2><a name="description" id="description">Description</a></h2>
  13. <p>This test a container, inserts into a number of values,
  14. splits the container at the median, and joins the two
  15. containers. (If the containers are one of <tt>pb_ds</tt> 's
  16. trees, it splits and joins with the <tt>split</tt> and
  17. <tt>join</tt> method; otherwise, it uses the <tt>erase</tt> and
  18. <tt>insert</tt> methods.) It measures the time for splitting
  19. and joining the containers as a function of the number of
  20. values inserted.</p>
  21. <p>(The test was executed with <a href="http://gcc.gnu.org/viewcvs/*checkout*/trunk/libstdc%2B%2B-v3/testsuite/performance/ext/pb_ds/tree_split_join_timing.cc"><tt>tree_split_join_timing_test</tt></a>
  22. 200 200 2100)</p>
  23. <h2><a name="purpose" id="purpose">Purpose</a></h2>
  24. <p>The test checks the performance difference of <tt>join</tt>
  25. as opposed to a sequence of <tt>insert</tt> operations; by
  26. implication, this test checks the most efficient way to erase a
  27. sub-sequence from a tree-like-based container, since this can
  28. always be performed by a small sequence of splits and joins
  29. (see <a href="motivation.html#assoc_split_join_methods">Motivation::Associative
  30. Containers::Slightly Different Methods::Methods Related to
  31. Split and Join</a> and <a href="tree_based_containers.html#add_methods">Design::Associative
  32. Containers::Tree-Based Containers::Additional Methods</a>
  33. .)</p>
  34. <h2><a name="results" id="results">Results</a></h2>
  35. <p>Figures <a href="#NTG">NTG</a>, <a href="#NTM">NTM</a>, and
  36. <a href="#NTL">NTL</a> show the results for the native and
  37. tree-based containers in <a href="assoc_performance_tests.html#gcc"><u>g++</u></a>, <a href="assoc_performance_tests.html#msvc"><u>msvc++</u></a>, and
  38. <a href="assoc_performance_tests.html#local"><u>local</u></a>,
  39. respectively.</p>
  40. <div id="NTG_res_div">
  41. <div id="NTG_gcc">
  42. <div id="NTG_tree_split_join_timing_test">
  43. <div id="NTG_assoc">
  44. <div id="NTG_Native_and_tree-based_container_splits_and_joins"><div style="border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class="c1"><a name="NTG" id="NTG"><img src="tree_split_join_timing_test_gcc.png" alt="no image" /></a></h6>NTG: Native and tree-based container splits and joins - <a href="assoc_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_set-
  48. <tt>std::set</tt></li>
  49. <li>
  50. splay_tree_set-
  51. <a href="tree.html"><tt>tree</tt></a>
  52. with <tt>Tag</tt> = <a href="splay_tree_tag.html"><tt>splay_tree_tag</tt></a>
  53. , and <tt>Node_Update</tt> = <a href="null_tree_node_update.html"><tt>null_tree_node_update</tt></a>
  54. </li>
  55. <li>
  56. rb_tree_set-
  57. <a href="tree.html"><tt>tree</tt></a>
  58. with <tt>Tag</tt> = <a href="rb_tree_tag.html"><tt>rb_tree_tag</tt></a>
  59. , and <tt>Node_Update</tt> = <a href="null_tree_node_update.html"><tt>null_tree_node_update</tt></a>
  60. </li>
  61. <li>
  62. ov_tree_set-
  63. <a href="tree.html"><tt>tree</tt></a>
  64. with <tt>Tag</tt> = <a href="ov_tree_tag.html"><tt>ov_tree_tag</tt></a>
  65. , and <tt>Node_Update</tt> = <a href="null_tree_node_update.html"><tt>null_tree_node_update</tt></a>
  66. </li>
  67. </ol>
  68. </div><div style="width: 100%; height: 20px"></div></div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <div id="NTM_res_div">
  74. <div id="NTM_msvc">
  75. <div id="NTM_tree_split_join_timing_test">
  76. <div id="NTM_assoc">
  77. <div id="NTM_Native_and_tree-based_container_splits_and_joins"><div style="border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class="c1"><a name="NTM" id="NTM"><img src="tree_split_join_timing_test_msvc.png" alt="no image" /></a></h6>NTM: Native and tree-based container splits and joins - <a href="assoc_performance_tests.html#msvc">msvc++</a><p>In the above figure, the names in the legends have the following meaning:</p>
  78. <ol>
  79. <li>
  80. n_set-
  81. <tt>std::set</tt></li>
  82. <li>
  83. splay_tree_set-
  84. <a href="tree.html"><tt>tree</tt></a>
  85. with <tt>Tag</tt> = <a href="splay_tree_tag.html"><tt>splay_tree_tag</tt></a>
  86. , and <tt>Node_Update</tt> = <a href="null_tree_node_update.html"><tt>null_tree_node_update</tt></a>
  87. </li>
  88. <li>
  89. rb_tree_set-
  90. <a href="tree.html"><tt>tree</tt></a>
  91. with <tt>Tag</tt> = <a href="rb_tree_tag.html"><tt>rb_tree_tag</tt></a>
  92. , and <tt>Node_Update</tt> = <a href="null_tree_node_update.html"><tt>null_tree_node_update</tt></a>
  93. </li>
  94. <li>
  95. ov_tree_set-
  96. <a href="tree.html"><tt>tree</tt></a>
  97. with <tt>Tag</tt> = <a href="ov_tree_tag.html"><tt>ov_tree_tag</tt></a>
  98. , and <tt>Node_Update</tt> = <a href="null_tree_node_update.html"><tt>null_tree_node_update</tt></a>
  99. </li>
  100. </ol>
  101. </div><div style="width: 100%; height: 20px"></div></div>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. <div id="NTL_res_div">
  107. <div id="NTL_local">
  108. <div id="NTL_tree_split_join_timing_test">
  109. <div id="NTL_assoc">
  110. <div id="NTL_Native_and_tree-based_container_splits_and_joins"><div style = "border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class="c1"><a name="NTL" id= "NTL"><img src="tree_split_join_timing_test_local.png" alt="no image" /></a></h6>NTL: Native and tree-based container splits and joins - <a href = "assoc_performance_tests.html#local">local</a></div><div style = "width: 100%; height: 20px"></div></div>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. <h2><a name="observations" id="observations">Observations</a></h2>
  116. <p>In this test, the native red-black trees must be split and
  117. joined externally, through a sequence of <tt>erase</tt> and
  118. <tt>insert</tt> operations. This is clearly super-linear, and
  119. it is not that surprising that the cost is high.</p>
  120. <p><tt>pb_ds</tt> 's tree-based containers use in this test the
  121. <tt>split</tt> and <tt>join</tt> methods, which have lower
  122. complexity: the <tt>join</tt> method of a splay tree ( <a href="tree.html"><tt>tree</tt></a>
  123. with <tt>Tag =</tt> <a href="splay_tree_tag.html"><tt>splay_tree_tag</tt></a> ) is
  124. quadratic in the length of the longest root-leaf path, and
  125. linear in the total number of elements; the <tt>join</tt>
  126. method of a red-black tree ( <a href="tree.html"><tt>tree</tt></a>
  127. with <tt>Tag =</tt> <a href="rb_tree_tag.html"><tt>rb_tree_tag</tt></a> ) or an
  128. ordered-vector tree ( <a href="tree.html"><tt>tree</tt></a>
  129. with <tt>Tag =</tt> <a href="ov_tree_tag.html"><tt>ov_tree_tag</tt></a> ) is linear
  130. in the number of elements.</p>
  131. <p>Asides from orders of growth, <tt>pb_ds</tt> 's trees access
  132. their allocator very little in these operations, and some of
  133. them do not access it at all. This leads to lower constants in
  134. their complexity, and, for some containers, to exception-free
  135. splits and joins (which can be determined via <a href="assoc_container_traits.html"><tt>container_traits</tt></a>).</p>
  136. <p>It is important to note that <tt>split</tt> and
  137. <tt>join</tt> are not esoteric methods - they are the most
  138. efficient means of erasing a contiguous range of values from a
  139. tree based container.</p>
  140. </div>
  141. </body>
  142. </html>