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>Tree Order Statistics Timing Test</title>
8 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
12 <h1>Tree Order-Statistics Timing Test</h1>
13 <h2><a name="description" id="description">Description</a></h2>
14 <p>This test creates a container, inserts random integers into
15 the the container, and then checks the order-statistics of the
16 container's values. (If the container is one of <tt>pb_ds</tt>
17 's trees, it does this with the <tt>order_of_key</tt> method of
18 <a href="tree_order_statistics_node_update.html"><tt>tree_order_statistics_node_update</tt></a>
19 ; otherwise, it uses the <tt>find</tt> method and
20 <tt>std::distance</tt> .) It measures the average time for such
21 queries as a function of the number of values inserted.</p>
22 <p>(The test was executed with <a href="../../../../testsuite/performance/ext/pb_ds/tree_order_statistics_timing.cc"><tt>tree_order_statistics_timing_test</tt></a>
24 <h2><a name="purpose" id="purpose">Purpose</a></h2>
25 <p>The test checks the performance difference of policies based
26 on node-invariant as opposed to a external functions. (see
27 <a href="tree_based_containers.html#invariants">Design::Associative
28 Containers::Tree-Based Containers::Node Invariants</a> .)</p>
29 <h2><a name="results" id="results">Results</a></h2>
30 <p>Figures <a href="#NTG">NTG</a>, <a href="#NTM">NTM</a>, and
31 <a href="#NTL">NTL</a> show the results for the native and
32 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
33 <a href="assoc_performance_tests.html#local"><u>local</u></a>,
35 <div id="NTG_res_div">
37 <div id="NTG_tree_order_statistics_timing_test">
39 <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>
43 <tt>std::set</tt></li>
46 <a href="tree.html"><tt>tree</tt></a>
47 with <tt>Tag</tt> = <a href="splay_tree_tag.html"><tt>splay_tree_tag</tt></a>
48 , and <tt>Node_Update</tt> = <a href="tree_order_statistics_node_update.html"><tt>tree_order_statistics_node_update</tt></a>
52 <a href="tree.html"><tt>tree</tt></a>
53 with <tt>Tag</tt> = <a href="rb_tree_tag.html"><tt>rb_tree_tag</tt></a>
54 , and <tt>Node_Update</tt> = <a href="tree_order_statistics_node_update.html"><tt>tree_order_statistics_node_update</tt></a>
57 </div><div style="width: 100%; height: 20px"></div></div>
62 <div id="NTM_res_div">
64 <div id="NTM_tree_order_statistics_timing_test">
66 <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>
70 <tt>std::set</tt></li>
73 <a href="tree.html"><tt>tree</tt></a>
74 with <tt>Tag</tt> = <a href="splay_tree_tag.html"><tt>splay_tree_tag</tt></a>
75 , and <tt>Node_Update</tt> = <a href="tree_order_statistics_node_update.html"><tt>tree_order_statistics_node_update</tt></a>
79 <a href="tree.html"><tt>tree</tt></a>
80 with <tt>Tag</tt> = <a href="rb_tree_tag.html"><tt>rb_tree_tag</tt></a>
81 , and <tt>Node_Update</tt> = <a href="tree_order_statistics_node_update.html"><tt>tree_order_statistics_node_update</tt></a>
84 </div><div style="width: 100%; height: 20px"></div></div>
89 <div id="NTL_res_div">
91 <div id="NTL_tree_order_statistics_timing_test">
93 <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>
98 <h2><a name="observations" id="observations">Observations</a></h2>
99 <p>In this test, the native red-black tree can support
100 order-statistics queries only externally, by performing a
101 <tt>find</tt> (alternatively, <tt>lower_bound</tt> or
102 <tt>upper_bound</tt> ) and then using <tt>std::distance</tt> .
103 This is clearly linear, and it is not that surprising that the
105 <p><tt>pb_ds</tt> 's tree-based containers use in this test the
106 <tt>order_of_key</tt> method of <a href="tree_order_statistics_node_update.html"><tt>tree_order_statistics_node_update</tt></a>.
107 This method has only linear complexity in the length of the
108 root-node path. Unfortunately, the average path of a splay tree
109 (<a href="tree.html"><tt>tree</tt></a>
110 with <tt>Tag =</tt> <a href="splay_tree_tag.html"><tt>splay_tree_tag</tt></a> ) can
111 be higher than logarithmic; the longest path of a red-black
112 tree (<a href="tree.html"><tt>tree</tt></a>
113 with <tt>Tag =</tt> <a href="rb_tree_tag.html"><tt>rb_tree_tag</tt></a> ) is
114 logarithmic in the number of elements. Consequently, the splay
115 tree has worse performance than the red-black tree.</p>