PageRenderTime 255ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://bitbucket.org/pizzafactory/pf-gcc
HTML | 118 lines | 117 code | 1 blank | 0 comment | 0 complexity | b38e95012fbb6b481813768e87d59ed3 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 Order Statistics 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 Order-Statistics Timing Test</h1>
  12. <h2><a name="description" id="description">Description</a></h2>
  13. <p>This test creates a container, inserts random integers into
  14. the the container, and then checks the order-statistics of the
  15. container's values. (If the container is one of <tt>pb_ds</tt>
  16. 's trees, it does this with the <tt>order_of_key</tt> method of
  17. <a href="tree_order_statistics_node_update.html"><tt>tree_order_statistics_node_update</tt></a>
  18. ; otherwise, it uses the <tt>find</tt> method and
  19. <tt>std::distance</tt> .) It measures the average time for such
  20. queries as a function of the number of 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_order_statistics_timing.cc"><tt>tree_order_statistics_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 policies based
  25. on node-invariant as opposed to a external functions. (see
  26. <a href="tree_based_containers.html#invariants">Design::Associative
  27. Containers::Tree-Based Containers::Node Invariants</a> .)</p>
  28. <h2><a name="results" id="results">Results</a></h2>
  29. <p>Figures <a href="#NTG">NTG</a>, <a href="#NTM">NTM</a>, and
  30. <a href="#NTL">NTL</a> show the results for the native and
  31. 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
  32. <a href="assoc_performance_tests.html#local"><u>local</u></a>,
  33. respectively.</p>
  34. <div id="NTG_res_div">
  35. <div id="NTG_gcc">
  36. <div id="NTG_tree_order_statistics_timing_test">
  37. <div id="NTG_assoc">
  38. <div id="NTG_Native_and_tree-based_container_order-statistics_queries"><div style="border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class="c1"><a name="NTG" id="NTG"><img src="tree_order_statistics_timing_test_gcc.png" alt="no image" /></a></h6>NTG: Native and tree-based container order-statistics queries - <a href="assoc_performance_tests.html#gcc">g++</a><p>In the above figure, the names in the legends have the following meaning:</p>
  39. <ol>
  40. <li>
  41. n_set-
  42. <tt>std::set</tt></li>
  43. <li>
  44. splay_tree_ost_set-
  45. <a href="tree.html"><tt>tree</tt></a>
  46. with <tt>Tag</tt> = <a href="splay_tree_tag.html"><tt>splay_tree_tag</tt></a>
  47. , and <tt>Node_Update</tt> = <a href="tree_order_statistics_node_update.html"><tt>tree_order_statistics_node_update</tt></a>
  48. </li>
  49. <li>
  50. rb_tree_ost_set-
  51. <a href="tree.html"><tt>tree</tt></a>
  52. with <tt>Tag</tt> = <a href="rb_tree_tag.html"><tt>rb_tree_tag</tt></a>
  53. , and <tt>Node_Update</tt> = <a href="tree_order_statistics_node_update.html"><tt>tree_order_statistics_node_update</tt></a>
  54. </li>
  55. </ol>
  56. </div><div style="width: 100%; height: 20px"></div></div>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. <div id="NTM_res_div">
  62. <div id="NTM_msvc">
  63. <div id="NTM_tree_order_statistics_timing_test">
  64. <div id="NTM_assoc">
  65. <div id="NTM_Native_and_tree-based_container_order-statistics_queries"><div style="border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class="c1"><a name="NTM" id="NTM"><img src="tree_order_statistics_timing_test_msvc.png" alt="no image" /></a></h6>NTM: Native and tree-based container order-statistics queries - <a href="assoc_performance_tests.html#msvc">msvc++</a><p>In the above figure, the names in the legends have the following meaning:</p>
  66. <ol>
  67. <li>
  68. n_set-
  69. <tt>std::set</tt></li>
  70. <li>
  71. splay_tree_ost_set-
  72. <a href="tree.html"><tt>tree</tt></a>
  73. with <tt>Tag</tt> = <a href="splay_tree_tag.html"><tt>splay_tree_tag</tt></a>
  74. , and <tt>Node_Update</tt> = <a href="tree_order_statistics_node_update.html"><tt>tree_order_statistics_node_update</tt></a>
  75. </li>
  76. <li>
  77. rb_tree_ost_set-
  78. <a href="tree.html"><tt>tree</tt></a>
  79. with <tt>Tag</tt> = <a href="rb_tree_tag.html"><tt>rb_tree_tag</tt></a>
  80. , and <tt>Node_Update</tt> = <a href="tree_order_statistics_node_update.html"><tt>tree_order_statistics_node_update</tt></a>
  81. </li>
  82. </ol>
  83. </div><div style="width: 100%; height: 20px"></div></div>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. <div id="NTL_res_div">
  89. <div id="NTL_local">
  90. <div id="NTL_tree_order_statistics_timing_test">
  91. <div id="NTL_assoc">
  92. <div id="NTL_Native_and_tree-based_container_order-statistics_queries"><div style = "border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class="c1"><a name="NTL" id= "NTL"><img src="tree_order_statistics_timing_test_local.png" alt="no image" /></a></h6>NTL: Native and tree-based container order-statistics queries - <a href = "assoc_performance_tests.html#local">local</a></div><div style = "width: 100%; height: 20px"></div></div>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <h2><a name="observations" id="observations">Observations</a></h2>
  98. <p>In this test, the native red-black tree can support
  99. order-statistics queries only externally, by performing a
  100. <tt>find</tt> (alternatively, <tt>lower_bound</tt> or
  101. <tt>upper_bound</tt> ) and then using <tt>std::distance</tt> .
  102. This is clearly linear, and it is not that surprising that the
  103. cost is high.</p>
  104. <p><tt>pb_ds</tt> 's tree-based containers use in this test the
  105. <tt>order_of_key</tt> method of <a href="tree_order_statistics_node_update.html"><tt>tree_order_statistics_node_update</tt></a>.
  106. This method has only linear complexity in the length of the
  107. root-node path. Unfortunately, the average path of a splay tree
  108. (<a href="tree.html"><tt>tree</tt></a>
  109. with <tt>Tag =</tt> <a href="splay_tree_tag.html"><tt>splay_tree_tag</tt></a> ) can
  110. be higher than logarithmic; the longest path of a red-black
  111. tree (<a href="tree.html"><tt>tree</tt></a>
  112. with <tt>Tag =</tt> <a href="rb_tree_tag.html"><tt>rb_tree_tag</tt></a> ) is
  113. logarithmic in the number of elements. Consequently, the splay
  114. tree has worse performance than the red-black tree.</p>
  115. </div>
  116. </body>
  117. </html>