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

Float Algorithm Performance

Note that these tests are carefully designed to test performance of the underlying algorithms and not memory allocation or variable copying. As usual, performance results should be taken with a healthy dose of scepticism, and real-world performance may vary widely depending upon the specifics of the program. In each table relative times are given first, with the best performer given a score of 1. Total actual times are given in brackets, measured in seconds for 500000 operations.

Table 1.14. Operator +

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

1 (0.0575156s)

1 (0.0740086s)

1 (0.219073s)

gmp_float

2.45065 (0.14095s)

2.01398 (0.149052s)

1.09608 (0.240122s)

mpfr_float

2.6001 (0.149546s)

2.12079 (0.156957s)

1.09078 (0.23896s)


Table 1.15. Operator +(int)

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

1.46115 (0.0855392s)

2.60353 (0.114398s)

3.62562 (0.264905s)

gmp_float

1 (0.0585424s)

1 (0.0439398s)

1 (0.0730648s)

mpfr_float

2.40441 (0.14076s)

3.2877 (0.144461s)

2.40379 (0.175632s)


Table 1.16. Operator +(unsigned long long)

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

1 (0.118146s)

1 (0.144714s)

1 (0.315639s)

gmp_float

4.5555 (0.538213s)

3.83096 (0.554395s)

1.95079 (0.615745s)

mpfr_float

5.74477 (0.678719s)

4.85295 (0.702291s)

2.70354 (0.853342s)


Table 1.17. Operator +=(unsigned long long)

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

1 (0.101188s)

1 (0.122394s)

1 (0.251975s)

gmp_float

5.199 (0.526079s)

4.39327 (0.537712s)

2.42151 (0.610159s)

mpfr_float

6.08318 (0.615547s)

5.18525 (0.634645s)

3.1022 (0.781677s)


Table 1.18. Operator -

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

1 (0.0895163s)

1 (0.129248s)

1.5088 (0.374512s)

gmp_float

1.72566 (0.154474s)

1.22567 (0.158415s)

1 (0.248219s)

mpfr_float

1.83764 (0.164499s)

1.34284 (0.173559s)

1.00226 (0.248781s)


Table 1.19. Operator -(int)

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

1 (0.105285s)

1 (0.142741s)

1 (0.278718s)

gmp_float

2.34437 (0.246828s)

1.28814 (0.183871s)

1.00731 (0.280754s)

mpfr_float

2.8032 (0.295136s)

2.09178 (0.298582s)

1.25213 (0.34899s)


Table 1.20. Operator -(unsigned long long)

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

1 (0.13719s)

1 (0.184428s)

1 (0.344212s)

gmp_float

4.0804 (0.559791s)

3.06776 (0.565781s)

2.07736 (0.715053s)

mpfr_float

5.10114 (0.699828s)

3.88684 (0.716843s)

2.50074 (0.860784s)


Table 1.21. Operator -=(unsigned long long)

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

1 (0.100984s)

1 (0.123148s)

1 (0.246181s)

gmp_float

5.68353 (0.573944s)

4.68636 (0.577116s)

2.6958 (0.663655s)

mpfr_float

6.19738 (0.625834s)

5.18544 (0.638577s)

3.18738 (0.784673s)


Table 1.22. Operator *

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

1.03667 (0.284251s)

1.30576 (0.536527s)

1.44686 (4.81057s)

gmp_float

1 (0.274196s)

1 (0.410891s)

1 (3.32484s)

mpfr_float

1.24537 (0.341477s)

1.15785 (0.475749s)

1.1796 (3.92199s)


Table 1.23. Operator *(int)

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

3.97453 (0.240262s)

9.91222 (0.463473s)

50.7926 (4.36527s)

gmp_float

1 (0.0604505s)

1 (0.0467577s)

1 (0.0859431s)

mpfr_float

2.56974 (0.155342s)

3.56312 (0.166603s)

3.22964 (0.277565s)


Table 1.24. Operator *(unsigned long long)

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

1 (0.331877s)

1.01058 (0.586122s)

6.688 (4.7931s)

gmp_float

1.72433 (0.572266s)

1 (0.579987s)

1 (0.716672s)

mpfr_float

2.5553 (0.848047s)

1.74987 (1.0149s)

1.80403 (1.2929s)


Table 1.25. Operator *=(unsigned long long)

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

1 (0.321397s)

1.00772 (0.574887s)

6.65946 (4.7468s)

gmp_float

1.77419 (0.570218s)

1 (0.570482s)

1 (0.712791s)

mpfr_float

2.62172 (0.842611s)

1.77691 (1.01369s)

1.77511 (1.26528s)


Table 1.26. Operator /

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

2.96096 (4.00777s)

4.53244 (7.86435s)

6.11936 (51.5509s)

gmp_float

1 (1.35354s)

1 (1.73512s)

1 (8.42422s)

mpfr_float

1.30002 (1.75963s)

1.39045 (2.41261s)

1.66762 (14.0484s)


Table 1.27. Operator /(int)

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

8.60726 (1.8181s)

15.4122 (3.67479s)

34.5119 (24.729s)

gmp_float

1.24394 (0.262756s)

1 (0.238433s)

1 (0.716536s)

mpfr_float

1 (0.211229s)

1.12178 (0.26747s)

1.02237 (0.732562s)


Table 1.28. Operator /(unsigned long long)

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

2.10976 (1.97569s)

3.73601 (3.9133s)

11.3085 (25.4533s)

gmp_float

1 (0.936452s)

1 (1.04746s)

1 (2.25081s)

mpfr_float

1.3423 (1.257s)

1.51575 (1.58768s)

3.31513 (7.46175s)


Table 1.29. Operator /=(unsigned long long)

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

2.17401 (1.96883s)

3.79591 (3.8965s)

11.2328 (25.2606s)

gmp_float

1 (0.905621s)

1 (1.0265s)

1 (2.24882s)

mpfr_float

1.37953 (1.24933s)

1.53073 (1.57129s)

3.30546 (7.43339s)


Table 1.30. Operator construct

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

1 (0.00929804s)

1 (0.0268321s)

1 (0.0310685s)

gmp_float

30.8781 (0.287106s)

7.59969 (0.203916s)

6.51873 (0.202527s)

mpfr_float

23.5296 (0.218779s)

8.11058 (0.217624s)

7.16325 (0.222552s)


Table 1.31. Operator construct(unsigned)

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

1 (0.0603971s)

1 (0.0735485s)

1 (0.116464s)

gmp_float

3.91573 (0.236498s)

2.88171 (0.211945s)

1.81075 (0.210887s)

mpfr_float

4.90052 (0.295977s)

4.01118 (0.295017s)

2.62005 (0.305141s)


Table 1.32. Operator construct(unsigned long long)

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

1 (0.0610288s)

1 (0.0759005s)

1 (0.118511s)

gmp_float

8.26247 (0.504249s)

6.69042 (0.507806s)

4.32819 (0.51294s)

mpfr_float

10.1593 (0.620013s)

8.45884 (0.64203s)

5.51472 (0.653557s)


Table 1.33. Operator str

Backend

50 Bits

100 Bits

500 Bits

cpp_dec_float

2.95848 (0.0223061s)

3.33461 (0.033471s)

3.0159 (0.132732s)

gmp_float

1 (0.00753971s)

1 (0.0100374s)

1 (0.0440106s)

mpfr_float

1.25424 (0.00945658s)

1.24943 (0.012541s)

1.09428 (0.0481601s)


Test code was compiled with Microsoft Visual Studio 2010 with all optimisations turned on (/Ox), and used MPIR-2.3.0 and MPFR-3.0.0. The tests were run on 32-bit Windows Vista machine.


PrevUpHomeNext