summaryrefslogtreecommitdiff
path: root/libs/multiprecision/doc/html/boost_multiprecision/perf/int_real_world.html
blob: d734c0161a96fa1c59128dd03fd90b3db88baef3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Integer Real World Tests</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.77.1">
<link rel="home" href="../../index.html" title="Chapter&#160;1.&#160;Boost.Multiprecision">
<link rel="up" href="../perf.html" title="Performance Comparison">
<link rel="prev" href="realworld.html" title="Floating-Point Real World Tests">
<link rel="next" href="float_performance.html" title="Float Algorithm Performance">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="realworld.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="float_performance.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_multiprecision.perf.int_real_world"></a><a class="link" href="int_real_world.html" title="Integer Real World Tests">Integer Real
      World Tests</a>
</h3></div></div></div>
<p>
        The first set of <a href="../../../../performance/voronoi_performance.cpp" target="_top">tests</a>
        measure the times taken to execute the multiprecision part of the Voronoi-diagram
        builder from Boost.Polygon. The tests mainly create a large number of temporaries
        "just in case" multiprecision arithmetic is required, for comparison,
        also included in the tests is Boost.Polygon's own partial-multiprecision
        integer type which was custom written for this specific task:
      </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  Integer Type
                </p>
              </th>
<th>
                <p>
                  Relative Performance (Actual time in parenthesis)
                </p>
              </th>
</tr></thead>
<tbody>
<tr>
<td>
                <p>
                  polygon::detail::extended_int
                </p>
              </td>
<td>
                <p>
                  1(0.138831s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  int256_t
                </p>
              </td>
<td>
                <p>
                  1.19247(0.165551s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  int512_t
                </p>
              </td>
<td>
                <p>
                  1.23301(0.17118s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  int1024_t
                </p>
              </td>
<td>
                <p>
                  1.21463(0.168628s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  checked_int256_t
                </p>
              </td>
<td>
                <p>
                  1.31711(0.182855s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  checked_int512_t
                </p>
              </td>
<td>
                <p>
                  1.57413(0.218538s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  checked_int1024_t
                </p>
              </td>
<td>
                <p>
                  1.36992(0.190187s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  cpp_int
                </p>
              </td>
<td>
                <p>
                  1.63244(0.226632s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  mpz_int
                </p>
              </td>
<td>
                <p>
                  5.42511(0.753172s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  tom_int
                </p>
              </td>
<td>
                <p>
                  29.0793(4.03709s)
                </p>
              </td>
</tr>
</tbody>
</table></div>
<p>
        Note how for this use case, any dynamic allocation is a performance killer.
      </p>
<p>
        The next <a href="../../../../performance/miller_rabin_performance.cpp" target="_top">tests</a>
        measure the time taken to generate 1000 128-bit random numbers and test for
        primality using the Miller Rabin test. This is primarily a test of modular-exponentiation
        since that is the rate limiting step:
      </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  Integer Type
                </p>
              </th>
<th>
                <p>
                  Relative Performance (Actual time in parenthesis)
                </p>
              </th>
</tr></thead>
<tbody>
<tr>
<td>
                <p>
                  cpp_int
                </p>
              </td>
<td>
                <p>
                  5.25827(0.379597s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  cpp_int (no Expression templates)
                </p>
              </td>
<td>
                <p>
                  5.15675(0.372268s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  cpp_int (128-bit cache)
                </p>
              </td>
<td>
                <p>
                  5.10882(0.368808s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  cpp_int (256-bit cache)
                </p>
              </td>
<td>
                <p>
                  5.50623(0.397497s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  cpp_int (512-bit cache)
                </p>
              </td>
<td>
                <p>
                  4.82257(0.348144s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  cpp_int (1024-bit cache)
                </p>
              </td>
<td>
                <p>
                  5.00053(0.360991s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  int1024_t
                </p>
              </td>
<td>
                <p>
                  4.37589(0.315897s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  checked_int1024_t
                </p>
              </td>
<td>
                <p>
                  4.52396(0.326587s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  mpz_int
                </p>
              </td>
<td>
                <p>
                  1(0.0721905s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  mpz_int (no Expression templates)
                </p>
              </td>
<td>
                <p>
                  1.0248(0.0739806s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  tom_int
                </p>
              </td>
<td>
                <p>
                  2.60673(0.188181s)
                </p>
              </td>
</tr>
<tr>
<td>
                <p>
                  tom_int (no Expression templates)
                </p>
              </td>
<td>
                <p>
                  2.64997(0.191303s)
                </p>
              </td>
</tr>
</tbody>
</table></div>
<p>
        It's interesting to note that expression templates have little effect here
        - perhaps because the actual expressions involved are relatively trivial
        in this case - so the time taken for multiplication and division tends to
        dominate. Also note how increasing the internal cache size used by <code class="computeroutput"><span class="identifier">cpp_int</span></code> is quite effective in this case
        in cutting out memory allocations altogether - cutting about a third off
        the total runtime. Finally the much quicker times from GMP and tommath are
        down to their much better modular-exponentiation algorithms (GMP's is about
        5x faster). That's an issue which needs to be addressed in a future release
        for <a class="link" href="../tut/ints/cpp_int.html" title="cpp_int">cpp_int</a>.
      </p>
<p>
        Test code was compiled with Microsoft Visual Studio 2010 with all optimisations
        turned on (/Ox), and used MPIR-2.3.0 and <a href="http://www.mpfr.org" target="_top">MPFR</a>-3.0.0.
        The tests were run on 32-bit Windows Vista machine.
      </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2013 John Maddock and Christopher Kormanyos<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        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>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="realworld.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="float_performance.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>