OSDN Git Service

2007-01-18 Jerry DeLisle <jvdelisle@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / doc / html / ext / pb_ds / priority_queue_random_int_push_pop_timing_test.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
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>Priority Queue Random Int Push Pop 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>Priority Queue Random Integer <tt>push</tt> and
13     <tt>pop</tt> Timing Test</h1>
14 <h2><a name="description" id="description">Description</a></h2>
15 <p>This test inserts a number of values with i.i.d. integer
16     keys into a container using <tt>push</tt> , then removes them
17     using <tt>pop</tt> . It measures the average time for
18     <tt>push</tt> and <tt>pop</tt> as a function of the number of
19     values.</p>
20 <p>(The test was executed with <a href="../../../../testsuite/performance/ext/pb_ds/priority_queue_random_int_push_pop_timing.cc">
21 <tt>priority_queue_random_int_push_pop_timing_test</tt></a>
22     thirty_years_among_the_dead_preproc.txt 200 200 2100)</p>
23 <h2><a name="purpose" id="purpose">Purpose</a></h2>
24 <p>The test checks the effect of different underlying
25     data structures (see <a href="pq_design.html#pq_imp">Design::Priority
26     Queues::Implementations</a>).</p>
27 <h2><a name="results" id="results">Results</a></h2>
28 <p>Figures <a href="#NPG">NPG</a>, <a href="#NPM">NPM</a>, and
29     <a href="#NPL">NPL</a> shows the results for the native
30     priority queues and <tt>pb_ds</tt> 's priority queues in
31     <a href="pq_performance_tests.html#gcc"><u>g++</u></a>,
32     <a href="pq_performance_tests.html#msvc"><u>msvc++</u></a>, and
33     <a href="pq_performance_tests.html#local"><u>local</u></a>,
34     respectively.</p>
35 <div id="NPG_res_div">
36 <div id="NPG_gcc">
37 <div id="NPG_priority_queue_random_int_push_pop_timing_test">
38 <div id="NPG_pq">
39 <div id="NPG_Native_and__tt_pb_ds_455tt__priority_queue__tt_push_455tt___tt_pop_455tt__timing_test"><div style="border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class="c1"><a name="NPG" id="NPG"><img src="priority_queue_random_int_push_pop_timing_test_gcc.png" alt="no image" /></a></h6>NPG: Native and <tt>pb ds</tt> priority queue <tt>push</tt> <tt>pop</tt> timing test - <a href="pq_performance_tests.html#gcc">g++</a><p>In the above figure, the names in the legends have the following meaning:</p>
40 <ol>
41 <li>
42 thin_heap-
43 <a href="priority_queue.html"><tt>priority_queue</tt></a>
44  with <tt>Tag</tt> = <a href="thin_heap_tag.html"><tt>thin_heap_tag</tt></a>
45 </li>
46 <li>
47 rc_binomial_heap-
48 <a href="priority_queue.html"><tt>priority_queue</tt></a>
49  with <tt>Tag</tt> = <a href="rc_binomial_heap_tag.html"><tt>rc_binomial_heap_tag</tt></a>
50 </li>
51 <li>
52 binomial_heap-
53 <a href="priority_queue.html"><tt>priority_queue</tt></a>
54  with <tt>Tag</tt> = <a href="binomial_heap_tag.html"><tt>binomial_heap_tag</tt></a>
55 </li>
56 <li>
57 pairing_heap-
58 <a href="priority_queue.html"><tt>priority_queue</tt></a>
59  with <tt>Tag</tt> = <a href="pairing_heap_tag.html"><tt>pairing_heap_tag</tt></a>
60 </li>
61 <li>
62 n_pq_deque-
63 <tt>std::priority_queue</tt> adapting <tt>std::deque</tt></li>
64 <li>
65 n_pq_vector-
66 <tt>std::priority_queue</tt> adapting <tt>std::vector</tt></li>
67 <li>
68 binary_heap-
69 <a href="priority_queue.html"><tt>priority_queue</tt></a>
70  with <tt>Tag</tt> = <a href="binary_heap_tag.html"><tt>binary_heap_tag</tt></a>
71 </li>
72 </ol>
73 </div><div style="width: 100%; height: 20px"></div></div>
74 </div>
75 </div>
76 </div>
77 </div>
78 <div id="NPM_res_div">
79 <div id="NPM_msvc">
80 <div id="NPM_priority_queue_random_int_push_pop_timing_test">
81 <div id="NPM_pq">
82 <div id="NPM_Native_and__tt_pb_ds_455tt__priority_queue__tt_push_455tt___tt_pop_455tt__timing_test"><div style="border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class="c1"><a name="NPM" id="NPM"><img src="priority_queue_random_int_push_pop_timing_test_msvc.png" alt="no image" /></a></h6>NPM: Native and <tt>pb ds</tt> priority queue <tt>push</tt> <tt>pop</tt> timing test - <a href="pq_performance_tests.html#msvc">msvc++</a><p>In the above figure, the names in the legends have the following meaning:</p>
83 <ol>
84 <li>
85 thin_heap-
86 <a href="priority_queue.html"><tt>priority_queue</tt></a>
87  with <tt>Tag</tt> = <a href="thin_heap_tag.html"><tt>thin_heap_tag</tt></a>
88 </li>
89 <li>
90 rc_binomial_heap-
91 <a href="priority_queue.html"><tt>priority_queue</tt></a>
92  with <tt>Tag</tt> = <a href="rc_binomial_heap_tag.html"><tt>rc_binomial_heap_tag</tt></a>
93 </li>
94 <li>
95 binomial_heap-
96 <a href="priority_queue.html"><tt>priority_queue</tt></a>
97  with <tt>Tag</tt> = <a href="binomial_heap_tag.html"><tt>binomial_heap_tag</tt></a>
98 </li>
99 <li>
100 pairing_heap-
101 <a href="priority_queue.html"><tt>priority_queue</tt></a>
102  with <tt>Tag</tt> = <a href="pairing_heap_tag.html"><tt>pairing_heap_tag</tt></a>
103 </li>
104 <li>
105 n_pq_deque-
106 <tt>std::priority_queue</tt> adapting <tt>std::deque</tt></li>
107 <li>
108 n_pq_vector-
109 <tt>std::priority_queue</tt> adapting <tt>std::vector</tt></li>
110 <li>
111 binary_heap-
112 <a href="priority_queue.html"><tt>priority_queue</tt></a>
113  with <tt>Tag</tt> = <a href="binary_heap_tag.html"><tt>binary_heap_tag</tt></a>
114 </li>
115 </ol>
116 </div><div style="width: 100%; height: 20px"></div></div>
117 </div>
118 </div>
119 </div>
120 </div>
121 <div id="NPL_res_div">
122 <div id="NPL_local">
123 <div id="NPL_priority_queue_random_int_push_pop_timing_test">
124 <div id="NPL_pq">
125 <div id="NPL_Native_and__tt_pb_ds_455tt__priority_queue__tt_push_455tt___tt_pop_455tt__timing_test"><div style = "border-style: dotted; border-width: 1px; border-color: lightgray"><h6 class="c1"><a name="NPL" id= "NPL"><img src="priority_queue_random_int_push_pop_timing_test_local.png" alt="no image" /></a></h6>NPL: Native and <tt>pb ds</tt> priority queue <tt>push</tt> <tt>pop</tt> timing test - <a href = "pq_performance_tests.html#local">local</a></div><div style = "width: 100%; height: 20px"></div></div>
126 </div>
127 </div>
128 </div>
129 </div>
130 <h2><a name="observations" id="observations">Observations</a></h2>
131 <p>Binary heaps are the most suited for sequences of
132     <tt>push</tt> and <tt>pop</tt> operations of primitive types
133     (<i>e.g.</i> <tt><b>int</b></tt>s). This is explained in
134     <a href="priority_queue_random_int_push_timing_test.html">Priority
135     Queue Random Int <tt>push</tt> Timing Test</a> . (See <a href="priority_queue_text_push_pop_timing_test.html">Priority Queue
136     Text <tt>push</tt> Timing Test</a> for the case of primitive
137     types.)</p>
138 <p>At first glance it seems that the STL's vector-based
139     priority queue is approximately on par with <tt>pb_ds</tt>'s
140     corresponding priority queue. There are two differences
141     however:</p>
142 <ol>
143 <li>The STL's priority queue does not downsize the underlying
144       vector (or deque) as the priority queue becomes smaller
145       (see <a href="priority_queue_text_pop_mem_usage_test.html">Priority Queue
146       Text <tt>pop</tt> Memory Use Test</a>). It is therefore
147       gaining some speed at the expense of space.</li>
148 <li>From <a href="priority_queue_random_int_push_pop_timing_test.html">Priority
149       Queue Random Integer <tt>push</tt> and <tt>pop</tt> Timing
150       Test</a>, it seems that the STL's priority queue is slower in
151       terms of <tt>pus</tt> operations. Since the number of
152       <tt>pop</tt> operations is at most that of <tt>push</tt>
153       operations, the test here is the "best" for the STL's
154       priority queue.</li>
155 </ol>
156 <p><a href="pq_performance_tests.html#pq_observations">Priority-Queue
157     Performance Tests::Observations</a> discusses this further and
158     summarizes.</p>
159 </div>
160 </body>
161 </html>