2008-01-10 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / libstdc++-v3 / docs / html / ext / pb_ds / tree_text_find_find_timing_test.html
blob283bdf098cd630287d7ad05515f994d3db2a628e
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">
5 <head>
6 <meta name="generator" content="HTML Tidy for Linux/x86 (vers 12 April 2005), see www.w3.org" />
7 <title>Tree Text Find Timing Test</title>
8 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
9 </head>
10 <body>
11 <div id="page">
12 <h1>Tree-Based and Trie-Based Text <tt>find</tt> Find Timing
13 Test</h1>
14 <h2><a name="description" id="description">Description</a></h2>
15 <p>This test inserts a number of values with keys from an
16 arbitrary text ([<a href="references.html#wickland96thirty">wickland96thirty</a>]) into
17 a container, then performs a series of finds using
18 <tt>find</tt>. It measures the average time for <tt>find</tt>
19 as a function of the number of values inserted.</p>
20 <p>(The test was executed with <a href="../../../../testsuite/performance/ext/pb_ds/text_find_timing.cc"><tt>text_find_timing_test</tt></a>
21 thirty_years_among_the_dead_preproc.txt 200 200 2100)</p>
22 <h2><a name="purpose" id="purpose">Purpose</a></h2>
23 <p>The test checks the effect of different underlying
24 data structures.</p>
25 <h2><a name="results" id="results">Results</a></h2>
26 <p>Figures <a href="#NTTG">NTTG</a>, <a href="#NTTM">NTTM</a>,
27 and <a href="#NTTG">NTTL</a> show the results for the native,
28 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
29 <a href="assoc_performance_tests.html#local"><u>local</u></a>,
30 respectively.</p>
31 <div id="NTTG_res_div">
32 <div id="NTTG_gcc">
33 <div id="NTTG_text_find_timing_test_tree_like">
34 <div id="NTTG_assoc">
35 <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>
36 <ol>
37 <li>
38 splay_tree_map-
39 <a href="tree.html"><tt>tree</tt></a>
40 with <tt>Tag</tt> = <a href="splay_tree_tag.html"><tt>splay_tree_tag</tt></a>
41 , and <tt>Node_Update</tt> = <a href="null_tree_node_update.html"><tt>null_tree_node_update</tt></a>
42 </li>
43 <li>
44 ov_tree_map-
45 <a href="tree.html"><tt>tree</tt></a>
46 with <tt>Tag</tt> = <a href="ov_tree_tag.html"><tt>ov_tree_tag</tt></a>
47 , and <tt>Node_Update</tt> = <a href="null_tree_node_update.html"><tt>null_tree_node_update</tt></a>
48 </li>
49 <li>
50 rb_tree_map-
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="null_tree_node_update.html"><tt>null_tree_node_update</tt></a>
54 </li>
55 <li>
56 n_map-
57 <tt>std::map</tt></li>
58 <li>
59 pat_trie_map-
60 <a href="trie.html"><tt>trie</tt></a>
61 with <tt>Tag</tt> = <a href="pat_trie_tag.html"><tt>pat_trie_tag</tt></a>
62 , and <tt>Node_Update</tt> = <a href="null_trie_node_update.html"><tt>null_trie_node_update</tt></a>
63 </li>
64 </ol>
65 </div><div style="width: 100%; height: 20px"></div></div>
66 </div>
67 </div>
68 </div>
69 </div>
70 <div id="NTTM_res_div">
71 <div id="NTTM_msvc">
72 <div id="NTTM_text_find_timing_test_tree_like">
73 <div id="NTTM_assoc">
74 <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>
75 <ol>
76 <li>
77 splay_tree_map-
78 <a href="tree.html"><tt>tree</tt></a>
79 with <tt>Tag</tt> = <a href="splay_tree_tag.html"><tt>splay_tree_tag</tt></a>
80 , and <tt>Node_Update</tt> = <a href="null_tree_node_update.html"><tt>null_tree_node_update</tt></a>
81 </li>
82 <li>
83 ov_tree_map-
84 <a href="tree.html"><tt>tree</tt></a>
85 with <tt>Tag</tt> = <a href="ov_tree_tag.html"><tt>ov_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_map-
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 n_map-
96 <tt>std::map</tt></li>
97 <li>
98 pat_trie_map-
99 <a href="trie.html"><tt>trie</tt></a>
100 with <tt>Tag</tt> = <a href="pat_trie_tag.html"><tt>pat_trie_tag</tt></a>
101 , and <tt>Node_Update</tt> = <a href="null_trie_node_update.html"><tt>null_trie_node_update</tt></a>
102 </li>
103 </ol>
104 </div><div style="width: 100%; height: 20px"></div></div>
105 </div>
106 </div>
107 </div>
108 </div>
109 <div id="NTTL_res_div">
110 <div id="NTTL_local">
111 <div id="NTTL_text_find_timing_test_tree_like">
112 <div id="NTTL_assoc">
113 <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>
114 </div>
115 </div>
116 </div>
117 </div>
118 <h2><a name="observations" id="observations">Observations</a></h2>
119 <p>For this setting, a splay tree (<a href="tree.html"><tt>tree</tt></a>
120 with <tt>Tag =</tt> <a href="splay_tree_tag.html"><tt>splay_tree_tag</tt></a>) does
121 not do well. This is possibly due to two reasons:</p>
122 <ol>
123 <li>A splay tree is not guaranteed to be balanced [<a href="references.html#motwani95random">motwani95random</a>]. If a
124 splay tree contains <i>n</i> nodes, its average root-leaf
125 path can be <i>m &gt;&gt; log(n)</i>.</li>
126 <li>Assume a specific root-leaf search path has length
127 <i>m</i>, and the search-target node has distance <i>m'</i>
128 from the root. A red-black tree will require <i>m + 1</i>
129 comparisons to find the required node; a splay tree will
130 require <i>2 m'</i> comparisons. A splay tree, consequently,
131 can perform many more comparisons than a red-black tree.</li>
132 </ol>
133 <p>An ordered-vector tree (<a href="tree.html"><tt>tree</tt></a>
134 with <tt>Tag =</tt> <a href="ov_tree_tag.html"><tt>ov_tree_tag</tt></a>), a red-black
135 tree (<a href="tree.html"><tt>tree</tt></a>
136 with <tt>Tag =</tt> <a href="splay_tree_tag.html"><tt>rb_tree_tag</tt></a>), and the
137 native red-black tree all share approximately the same
138 performance.</p>
139 <p>An ordered-vector tree is slightly slower than red-black
140 trees, since it requires, in order to find a key, more math
141 operations than they do. Conversely, an ordered-vector tree
142 requires far lower space than the others. ([<a href="references.html#austern00noset">austern00noset</a>], however,
143 seems to have an implementation that is also faster than a
144 red-black tree).</p>
145 <p>A PATRICIA trie (<a href="trie.html"><tt>trie</tt></a>
146 with <tt>Tag =</tt> <a href="pat_trie_tag.html"><tt>pat_trie_tag</tt></a>) has good
147 look-up performance, due to its large fan-out in this case. In
148 this setting, a PATRICIA trie has look-up performance comparable
149 to a hash table (see <a href="hash_text_find_find_timing_test.html">Hash-Based Text
150 <tt>find</tt> Find Timing Test</a>), but it is order
151 preserving. This is not that surprising, since a large-fan-out
152 PATRICIA trie works like a hash table with collisions resolved
153 by a sub-trie. A large-fan-out PATRICIA trie does not do well on
154 modifications (see <a href="tree_text_insert_timing_test.html">Tree-Based and Trie-Based
155 Text Insert Timing Test</a>). It is possibly beneficial to
156 semi-static settings, therefore.</p>
157 <p><a href="assoc_performance_tests.html#tree_like_based_types">Observations::Tree-Like-Based
158 Container Types</a> summarizes some observations on tree-based
159 and trie-based containers.</p>
160 </div>
161 </body>
162 </html>