File: random-performance.html

package info (click to toggle)
boost 1.27.0-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 19,908 kB
  • ctags: 26,546
  • sloc: cpp: 122,225; ansic: 10,956; python: 4,412; sh: 855; yacc: 803; makefile: 257; perl: 165; lex: 90; csh: 6
file content (241 lines) | stat: -rw-r--r-- 3,633 bytes parent folder | download | duplicates (3)
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
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Boost Random Number Library Performance</title>
</head>

<body bgcolor="#FFFFFF" text="#000000">

<h1>Random Number Library Performance</h1>

For some people, performance of random number generation is an
important consideration when choosing a random number generator or a
particular distribution function.  This page provides numerous
performance tests with the wide variety of generators and
distributions available in the boost library.
<p>
The performance has been evaluated on a Pentium Pro 200 MHz with gcc
2.95.2, Linux 2.2.13, glibc 2.1.2.  The speed is reported in million
random numbers per second (M rn/sec), generated in a tight loop.
<p>


<h2>Basic Generators</h2>

<table border="1">

<tr>
<th>generator</th>
<th>M rn/sec</th>
<th>time per random number [usec]</th>
<th>relative speed compared to fastest [percent]</th>
</tr>

<tr>
<td>rand48</td>
<td>5.38</td>
<td>0.183</td>
<td>61%</td>
</tr>

<tr>
<td>rand48 run-time configurable</td>
<td>1.48</td>
<td>0.677</td>
<td>17%</td>
</tr>

<tr>
<td>lrand48 glibc 2.1.2</td>
<td>1.19</td>
<td>0.843</td>
<td>13%</td>
</tr>

<tr>
<td>minstd_rand</td>
<td>2.39</td>
<td>0.318</td>
<td>35%</td>
</tr>

<tr>
<td>ecuyer1988</td>
<td>1.12</td>
<td>0.892</td>
<td>13%</td>
</tr>

<tr>
<td>kreutzer1986</td>
<td>3.87</td>
<td>0.258</td>
<td>43%</td>
</tr>

<tr>
<td>hellekalek1995 (inversive)</td>
<td>0.20</td>
<td>5.12</td>
<td>2%</td>
</tr>

<tr>
<td>mt11213b</td>
<td>6.07</td>
<td>0.165</td>
<td>68%</td>
</tr>

<tr>
<td>mt19937</td>
<td>6.06</td>
<td>0.165</td>
<td>68%</td>
</tr>

<tr>
<td>mt19937 original</td>
<td>5.33</td>
<td>0.188</td>
<td>60%</td>
</tr>

<tr>
<td>lagged_fibonacci607</td>
<td>8.90</td>
<td>0.112</td>
<td>100%</td>
</tr>

<tr>
<td>lagged_fibonacci4423</td>
<td>8.54</td>
<td>0.117</td>
<td>96%</td>
</tr>

<tr>
<td>lagged_fibonacci19937</td>
<td>7.49</td>
<td>0.133</td>
<td>84%</td>
</tr>

<tr>
<td>lagged_fibonacci23209</td>
<td>6.63</td>
<td>0.151</td>
<td>74%</td>
</tr>

<tr>
<td>lagged_fibonacci44497</td>
<td>4.01</td>
<td>0.250</td>
<td>45%</td>
</tr>

</table>
<p>
Note that the lagged Fibonacci generators produce floating-point
numbers, whereas all others produce integers.

<h2>Distributions</h2>

<table border="1">

<tr>
<th>[M rn/sec]</th>
<th>minstd_rand</th>
<th>kreutzer1986</th>
<th>mt19937</th>
<th>lagged_fibonacci607</th>
</tr>

<tr>
<th>uniform_smallint</th>
<td>1.26</td>
<td>1.55</td>
<td>1.93</td>
<td>-</td>
</tr>

<tr>
<th>uniform_01</th>
<td>1.79</td>
<td>1.88</td>
<td>3.03</td>
<td>7.74</td>
</tr>

<tr>
<th>uniform_real</th>
<td>1.74</td>
<td>1.56</td>
<td>2.34</td>
<td>6.62</td>
</tr>

<tr>
<th>geometric</th>
<td>0.593</td>
<td>0.629</td>
<td>0.753</td>
<td>0.916</td>
</tr>

<tr>
<th>triangle</th>
<td>0.97</td>
<td>1.02</td>
<td>1.35</td>
<td>1.31</td>
</tr>

<tr>
<th>exponential</th>
<td>0.849</td>
<td>0.828</td>
<td>0.887</td>
<td>1.53</td>
</tr>

<tr>
<th>normal (polar method)</th>
<td>0.608</td>
<td>0.626</td>
<td>0.738</td>
<td>0.755</td>
</tr>

<tr>
<th>lognormal</th>
<td>0.417</td>
<td>0.442</td>
<td>0.470</td>
<td>0.481</td>
</tr>

<tr>
<th>uniform_on_sphere</th>
<td>0.154</td>
<td>0.155</td>
<td>0.174</td>
<td>0.218</td>
</tr>

</table>
<p>
Note that the lagged Fibonacci generator is at least 2.5 times faster
than the Mersenne twister when generating uniformly distributed
floating-point numbers.  For more sophisticated distributions, the
speed improvement is less.  Note however that these distributions have
not been optimized for speed, yet.
<p>
<hr>
Jens Maurer, 2001-04-15

</body>
</html>