Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Performance

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.

The performance has been evaluated on an Intel(R) Xeon(TM) MP CPU 3.66GHz, Gentoo Base System release 1.12.11.1, GCC 4.3.2, glibc 2.9 and on an Intel(R) Core(TM)2 CPU T7600 @2.33 Ghz with Microsoft Windows XP Professional, Service Pack 2 Build 2600, Microsoft Visual C++ 2008 9.0.21022. The speed is reported in million random numbers per second (M rn/sec), generated in a tight loop.

Table 16.7. Basic Generators (Linux)

generator

M rn/sec

time per random number [nsec]

relative speed compared to fastest [percent]

rand48

312.5

3.2

100%

lrand48 run-time

303.03

3.3

96%

lrand48 (C library)

67.5676

14.8

21%

minstd_rand0

96.1538

10.4

30%

minstd_rand

93.4579

10.7

29%

ecuyer combined

60.6061

16.5

19%

kreutzer1986

97.0874

10.3

31%

taus88

243.902

4.1

78%

hellekalek1995 (inversive)

2.405

415.8

0%

mt11213b

138.889

7.2

44%

mt19937

138.889

7.2

44%

lagged_fibonacci607

81.9672

12.2

26%

lagged_fibonacci1279

81.9672

12.2

26%

lagged_fibonacci2281

81.9672

12.2

26%

lagged_fibonacci3217

81.3008

12.3

26%

lagged_fibonacci4423

80.6452

12.4

25%

lagged_fibonacci9689

80.6452

12.4

25%

lagged_fibonacci19937

80

12.5

25%

lagged_fibonacci23209

80.6452

12.4

25%

lagged_fibonacci44497

79.3651

12.6

25%

subtract_with_carry

76.9231

13

24%

subtract_with_carry_01

45.045

22.2

14%

ranlux3

8.78735

113.8

2%

ranlux4

5.11771

195.4

1%

ranlux3_01

5.29381

188.9

1%

ranlux4_01

3.04599

328.3

0%

ranlux64_3

8.74126

114.4

2%

ranlux64_4

5.09684

196.2

1%

ranlux64_3_01

5.30786

188.4

1%

ranlux64_4_01

3.02847

330.2

0%

mt19937ar.c

95.2381

10.5

30%


Table 16.8. Basic Generators (Windows)

generator

M rn/sec

time per random number [nsec]

relative speed compared to fastest [percent]

rand48

98.5222

10.15

67%

lrand48 run-time

17.343

57.66

11%

minstd_rand0

46.3822

21.56

31%

minstd_rand

38.5505

25.94

26%

ecuyer combined

15.8028

63.28

10%

kreutzer1986

66.6667

15

45%

taus88

145.56

6.87

100%

hellekalek1995 (inversive)

4.26658

234.38

2%

mt11213b

139.082

7.19

95%

mt19937

142.248

7.03

97%

lagged_fibonacci607

61.5385

16.25

42%

lagged_fibonacci1279

58.7199

17.03

40%

lagged_fibonacci2281

64.0205

15.62

43%

lagged_fibonacci3217

62.1118

16.1

42%

lagged_fibonacci4423

63.3714

15.78

43%

lagged_fibonacci9689

64.6412

15.47

44%

lagged_fibonacci19937

63.3714

15.78

43%

lagged_fibonacci23209

64.6412

15.47

44%

lagged_fibonacci44497

64.0205

15.62

43%

subtract_with_carry

92.7644

10.78

63%

subtract_with_carry_01

78.0031

12.82

53%

ranlux3

9.86193

101.4

6%

ranlux4

5.80754

172.19

3%

ranlux3_01

7.15103

139.84

4%

ranlux4_01

3.8345

260.79

2%

ranlux64_3

9.10415

109.84

6%

ranlux64_4

5.05919

197.66

3%

ranlux64_3_01

6.12445

163.28

4%

ranlux64_4_01

3.39167

294.84

2%

mt19937ar.c

125.471

7.97

86%


Note that the lagged Fibonacci and ranlux_01 generators produce floating-point numbers, whereas all others produce integers.

Table 16.9. Distributions (Linux)

[M rn/sec]

minstd_rand

kreutzer1986

mt19937

lagged_fibonacci607

uniform_int

31.25

30.581

11.5607

16.0514

geometric

5.20833

6.66223

6.68449

6.73854

binomial

5.01505

21.7865

4.38982

10.9529

poisson

22.8311

22.1729

20.8768

24.3902

uniform_real

18.2815

84.0336

67.1141

72.4638

triangle

13.2802

33.4448

33.67

36.4964

exponential

6.19195

8.49618

8.2713

8.65052

normal polar

5.78369

6.56599

6.49773

6.48508

lognormal

4.13565

4.53515

4.51467

4.57875

cauchy

6.07533

7.92393

7.77605

8.35422

gamma

6.07533

7.92393

7.83085

8.34725

uniform_on_sphere

1.43472

1.62075

1.5625

1.5949


Table 16.10. Distributions (Windows)

[M rn/sec]

minstd_rand

kreutzer1986

mt19937

lagged_fibonacci607

uniform_int

14.7449

27.465

6.65292

28.5714

geometric

7.10328

5.53649

3.73622

9.38438

binomial

6.20155

5.78135

2.65118

4.65463

poisson

15.9617

8.77886

12.5486

17.9276

uniform_real

49.6032

27.1223

31.6857

60.35

triangle

21.3356

11.7

14.2857

22.3015

exponential

14.3493

6.05473

10.8472

12.982

normal polar

4.24394

2.75748

7.04871

6.09533

lognormal

3.30066

1.34822

5.36913

4.0024

cauchy

11.4286

2.92372

12.0525

7.55629

gamma

10.5263

3.72523

12.1433

5.87682

uniform_on_sphere

0.680874

0.38004

1.18737

0.486334



PrevUpHomeNext