Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / multiprecision / doc / html / boost_multiprecision / perf / overhead.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>The Overhead in the Number Class Wrapper</title>
5 <link rel="stylesheet" href="../../multiprecision.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Boost.Multiprecision">
8 <link rel="up" href="../perf.html" title="Performance Comparison">
9 <link rel="prev" href="../perf.html" title="Performance Comparison">
10 <link rel="next" href="realworld.html" title="Floating-Point Real World Tests">
11 </head>
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
15 <td align="center"><a href="../../../../../../index.html">Home</a></td>
16 <td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../../../../../more/index.htm">More</a></td>
20 </tr></table>
21 <hr>
22 <div class="spirit-nav">
23 <a accesskey="p" href="../perf.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../perf.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="realworld.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
24 </div>
25 <div class="section">
26 <div class="titlepage"><div><div><h3 class="title">
27 <a name="boost_multiprecision.perf.overhead"></a><a class="link" href="overhead.html" title="The Overhead in the Number Class Wrapper">The Overhead in the
28       Number Class Wrapper</a>
29 </h3></div></div></div>
30 <p>
31         Using a simple <a href="../../../../performance/arithmetic_backend.hpp" target="_top">backend
32         class</a> that wraps any built in arithmetic type we can measure the
33         overhead involved in wrapping a type inside the <code class="computeroutput"><span class="identifier">number</span></code>
34         frontend, and the effect that turning on expression templates has. The following
35         table compares the performance between <code class="computeroutput"><span class="keyword">double</span></code>
36         and a <code class="computeroutput"><span class="keyword">double</span></code> wrapped inside
37         class <code class="computeroutput"><span class="identifier">number</span></code>:
38       </p>
39 <div class="informaltable"><table class="table">
40 <colgroup>
41 <col>
42 <col>
43 <col>
44 </colgroup>
45 <thead><tr>
46 <th>
47                 <p>
48                   Type
49                 </p>
50               </th>
51 <th>
52                 <p>
53                   Bessel Function Evaluation
54                 </p>
55               </th>
56 <th>
57                 <p>
58                   Non-Central T Evaluation
59                 </p>
60               </th>
61 </tr></thead>
62 <tbody>
63 <tr>
64 <td>
65                 <p>
66                   <code class="computeroutput"><span class="keyword">double</span></code>
67                 </p>
68               </td>
69 <td>
70                 <p>
71                   <span class="bold"><strong>1.0 (0.016s)</strong></span>
72                 </p>
73               </td>
74 <td>
75                 <p>
76                   <span class="bold"><strong>1.0</strong></span> (0.46s)
77                 </p>
78               </td>
79 </tr>
80 <tr>
81 <td>
82                 <p>
83                   <code class="computeroutput"><span class="identifier">number</span><span class="special">&lt;</span><span class="identifier">arithmetic_backend</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;,</span>
84                   <span class="identifier">et_off</span><span class="special">&gt;</span></code>
85                 </p>
86               </td>
87 <td>
88                 <p>
89                   1.2 (0.019s)
90                 </p>
91               </td>
92 <td>
93                 <p>
94                   <span class="bold"><strong>1.0</strong></span>(0.46s)
95                 </p>
96               </td>
97 </tr>
98 <tr>
99 <td>
100                 <p>
101                   <code class="computeroutput"><span class="identifier">number</span><span class="special">&lt;</span><span class="identifier">arithmetic_backend</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;,</span>
102                   <span class="identifier">et_on</span><span class="special">&gt;</span></code>
103                 </p>
104               </td>
105 <td>
106                 <p>
107                   1.2 (0.019s)
108                 </p>
109               </td>
110 <td>
111                 <p>
112                   1.7 (0.79s)
113                 </p>
114               </td>
115 </tr>
116 </tbody>
117 </table></div>
118 <p>
119         As you can see whether or not there is an overhead, and how large it is depends
120         on the actual situation, but the overhead is in any cases small. Expression
121         templates generally add a greater overhead the more complex the expression
122         becomes due to the logic of figuring out how to best unpack and evaluate
123         the expression, but of course this is also the situation where you save more
124         temporaries. For a "trivial" backend like this, saving temporaries
125         has no benefit, but for larger types it becomes a bigger win.
126       </p>
127 <p>
128         The following table compares arithmetic using either <code class="computeroutput"><span class="keyword">long</span>
129         <span class="keyword">long</span></code> or <code class="computeroutput"><span class="identifier">number</span><span class="special">&lt;</span><span class="identifier">arithmetic_backend</span><span class="special">&lt;</span><span class="keyword">long</span> <span class="keyword">long</span><span class="special">&gt;</span> <span class="special">&gt;</span></code> for the <a href="../../../../performance/voronoi_performance.cpp" target="_top">voronoi-diagram
130         builder test</a>:
131       </p>
132 <div class="informaltable"><table class="table">
133 <colgroup>
134 <col>
135 <col>
136 </colgroup>
137 <thead><tr>
138 <th>
139                 <p>
140                   Type
141                 </p>
142               </th>
143 <th>
144                 <p>
145                   Relative time
146                 </p>
147               </th>
148 </tr></thead>
149 <tbody>
150 <tr>
151 <td>
152                 <p>
153                   <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">long</span></code>
154                 </p>
155               </td>
156 <td>
157                 <p>
158                   <span class="bold"><strong>1.0</strong></span>(0.0823s)
159                 </p>
160               </td>
161 </tr>
162 <tr>
163 <td>
164                 <p>
165                   <code class="computeroutput"><span class="identifier">number</span><span class="special">&lt;</span><span class="identifier">arithmetic_backend</span><span class="special">&lt;</span><span class="keyword">long</span> <span class="keyword">long</span><span class="special">&gt;,</span> <span class="identifier">et_off</span><span class="special">&gt;</span></code>
166                 </p>
167               </td>
168 <td>
169                 <p>
170                   1.05 (0.0875s)
171                 </p>
172               </td>
173 </tr>
174 </tbody>
175 </table></div>
176 <p>
177         This test involves mainly creating a lot of temporaries and performing a
178         small amount of arithmetic on them, with very little difference in performance
179         between the native and "wrapped" types.
180       </p>
181 <p>
182         The test code was compiled with Microsoft Visual Studio 2010 with all optimisations
183         turned on (/Ox), and used MPIR-2.3.0 and <a href="http://libtom.net" target="_top">libtommath</a>-0.42.0.
184         The tests were run on 32-bit Windows Vista machine.
185       </p>
186 </div>
187 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
188 <td align="left"></td>
189 <td align="right"><div class="copyright-footer">Copyright &#169; 2002-2019 John Maddock
190       and Christopher Kormanyos<p>
191         Distributed under the Boost Software License, Version 1.0. (See accompanying
192         file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
193       </p>
194 </div></td>
195 </tr></table>
196 <hr>
197 <div class="spirit-nav">
198 <a accesskey="p" href="../perf.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../perf.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="realworld.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
199 </div>
200 </body>
201 </html>