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 Text Find Timing Test
</title>
8 <meta http-equiv=
"Content-Type" content=
"text/html; charset=us-ascii" />
12 <h1>Tree-Based and Trie-Based Text
<tt>find
</tt> Find Timing
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
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>,
31 <div id=
"NTTG_res_div">
33 <div id=
"NTTG_text_find_timing_test_tree_like">
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>
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>
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>
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>
57 <tt>std::map
</tt></li>
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>
65 </div><div style=
"width: 100%; height: 20px"></div></div>
70 <div id=
"NTTM_res_div">
72 <div id=
"NTTM_text_find_timing_test_tree_like">
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>
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>
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>
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>
96 <tt>std::map
</tt></li>
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>
104 </div><div style=
"width: 100%; height: 20px"></div></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>
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>
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
>> 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>
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
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
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>