Skip to content

Commit

Permalink
Merge pull request #510 from cppalliance/More_benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
mborland authored Apr 26, 2024
2 parents e72a5fd + 4bb8f5b commit de615c0
Show file tree
Hide file tree
Showing 2 changed files with 543 additions and 90 deletions.
298 changes: 246 additions & 52 deletions doc/decimal/benchmarks.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,36 @@ An example on Linux with b2: `../../../b2 cxxstd=20 toolset=gcc-13 define=BOOST_

== Comparisons

The benchmark for comparisons generates a random vector containing 10,000,000 elements and does operations `>`, `>=`, `<`, `<=`, `==`, and `!=` between `vec[i] and vec[i + 1]`.
The benchmark for comparisons generates a random vector containing 2,000,000 elements and does operations `>`, `>=`, `<`, `<=`, `==`, and `!=` between `vec[i] and vec[i + 1]`.
This is repeated 5 times to generate stable results.

=== M1 macOS Results

Run using a Macbook pro with M1 pro chipset running macOS Sonoma 14.4.1 and homebrew Clang 18.1.4

|===
| Type | Runtime (ms) | Ratio to `double`
| Type | Runtime (us) | Ratio to `double`
| `float`
| 8
| 1.333
| 9032
| 1.589
| `double`
| 6
| 5684
| 1.000
| `decimal32`
| 380
| 63.333
| 285,453
| 50.2204
| `decimal64`
| 408
| 608.000
| 352,644
| 62.042
| `decimal128`
| 14641
| 2440.170
| 15,355,817
| 2701.590
|===

== Basic Operations

The benchmark for these operations generates a random vector containing 10,000,000 elements and does operations `+`, `-`, `*`, `/` between `vec[i] and vec[i + 1]`.
The benchmark for these operations generates a random vector containing 2,000,000 elements and does operations `+`, `-`, `*`, `/` between `vec[i] and vec[i + 1]`.
This is repeated 5 times to generate stable results.

=== M1 macOS Results

Expand All @@ -58,83 +60,275 @@ Run using a Macbook pro with M1 pro chipset running macOS Sonoma 14.4.1 and home
==== Addition

|===
| Type | Runtime (ms) | Ratio to `double`
| Type | Runtime (us) | Ratio to `double`
| `float`
| 6
| 1.500
| 1641
| 0.965
| `double`
| 4
| 1708
| 1.000
| `decimal32`
| 361
| 90.250
| 378,252
| 221.459
| `decimal64`
| 568
| 142.000
| 589,313
| 345.031
| `decimal128`
| 13428
| 3357.000
| 13,829,995
| 8097.190
|===

==== Subtraction

|===
| Type | Runtime (ms) | Ratio to `double`
| Type | Runtime (us) | Ratio to `double`
| `float`
| 3
| 3.000
| 3633
| 2.221
| `double`
| 1
| 1636
| 1.000
| `decimal32`
| 307
| 307.000
| 307,765
| 188.120
| `decimal64`
| 465
| 465.000
| 461,442
| 282.055
| `decimal128`
| 11444
| 11444.000
| 11,449,306
| 6998.350
|===

==== Multiplication

|===
| Type | Runtime (ms) | Ratio to `double`
| Type | Runtime (us) | Ratio to `double`
| `float`
| 1
| 0.333
| 1678
| 0.523
| `double`
| 3
| 3209
| 1.000
| `decimal32`
| 311
| 103.667
| 310,543
| 96.773
| `decimal64`
| 569
| 189.667
| 570,938
| 177.918
| `decimal128`
| 9430
| 3143.330
| 9,434,297
| 2939.95
|===

==== Division

|===
| Type | Runtime (ms) | Ratio to `double`
| Type | Runtime (us) | Ratio to `double`
| `float`
| 2
| 0.667
| 2019
| 0.565
| `double`
| 3
| 3572
| 1.000
| `decimal32`
| 319
| 106.333
| 322,116
| 90.178
| `decimal64`
| 395
| 131.667
| 734,173
| 205.536
| `decimal128`
| 14781
| 4927.000
| 14,592,284
| 4085.19
|===

== Selected Special Functions

The benchmark for these operations generates a random vector containing 2,000,000 elements and does operations `+`, `-`, `*`, `/` between `vec[i] and vec[i + 1]`.
This is repeated 5 times to generate stable results.

=== M1 macOS Results

Run using a Macbook pro with M1 pro chipset running macOS Sonoma 14.4.1 and homebrew Clang 18.1.4

==== SQRT

|===
| Type | Runtime (us) | Ratio to `double`
| `float`
| 1904
| 0.565
| `double`
| 3746
| 1.000
| `decimal32`
| 5,050,241
| 1341.72
| `decimal64`
| 12,084,821
| 3210.630
| `decimal128`
| 275,779,340
| 73267.60
|===

== `<charconv>`

For all the following the results compare against https://github.com/boostorg/charconv[boost.charconv] for 10'000'000 conversions.

=== `from_chars` general

==== M1 macOS Results

Run using a Macbook pro with M1 pro chipset running macOS Sonoma 14.4.1 and homebrew Clang 18.1.4

|===
| Type | Runtime (us) | Ratio to `double`
| `float`
| 235,816
| 0.953
| `double`
| 247,307
| 1.000
| `decimal32`
| 366,682
| 1.483
| `decimal64`
| 485,965
| 1.965
// Decimal128 was two orders of magnitude faster. I expect an issue
//| `decimal128`
//| 275,779,340
//| 73267.60
|===

NOTE: `decimal128` is currently absent due to results showing it is 2 orders of magnitude faster than the others.
This should not be the case so will be investigated.

=== `from_chars` scientific

==== M1 macOS Results

Run using a Macbook pro with M1 pro chipset running macOS Sonoma 14.4.1 and homebrew Clang 18.1.4

|===
| Type | Runtime (us) | Ratio to `double`
| `float`
| 241,893
| 0.975
| `double`
| 247,975
| 1.000
| `decimal32`
| 358,189
| 1.444
| `decimal64`
| 477,574
| 1.926
// Decimal128 was two orders of magnitude faster. I expect an issue
//| `decimal128`
//| 275,779,340
//| 73267.60
|===

NOTE: `decimal128` is currently absent due to results showing it is 2 orders of magnitude faster than the others.
This should not be the case so will be investigated.

=== `to_chars` general shortest representation

==== M1 macOS Results

Run using a Macbook pro with M1 pro chipset running macOS Sonoma 14.4.1 and homebrew Clang 18.1.4

|===
| Type | Runtime (us) | Ratio to `double`
| `float`
| 316,300
| 1.040
| `double`
| 304,272
| 1.000
| `decimal32`
| 406,053
| 1.335
| `decimal64`
| 678,451
| 2.230
| `decimal128`
| 6,309,346
| 20.736
|===

=== `to_chars` general 6-digits of precision

==== M1 macOS Results

Run using a Macbook pro with M1 pro chipset running macOS Sonoma 14.4.1 and homebrew Clang 18.1.4

|===
| Type | Runtime (us) | Ratio to `double`
| `float`
| 323,867
| 0.967
| `double`
| 334,989
| 1.000
| `decimal32`
| 409,608
| 1.223
| `decimal64`
| 702,339
| 2.097
| `decimal128`
| 6,305,521
| 18.823
|===

=== `to_chars` scientific shortest representation

==== M1 macOS Results

Run using a Macbook pro with M1 pro chipset running macOS Sonoma 14.4.1 and homebrew Clang 18.1.4

|===
| Type | Runtime (us) | Ratio to `double`
| `float`
| 286,330
| 1.011
| `double`
| 283,287
| 1.000
| `decimal32`
| 290,117
| 1.024
| `decimal64`
| 499,637
| 1.764
| `decimal128`
| 3,096,910
| 10.932
|===

=== `to_chars` scientific 6-digits of precision

==== M1 macOS Results

Run using a Macbook pro with M1 pro chipset running macOS Sonoma 14.4.1 and homebrew Clang 18.1.4

|===
| Type | Runtime (us) | Ratio to `double`
| `float`
| 258,710
| 0.809
| `double`
| 319,676
| 1.000
| `decimal32`
| 292,250
| 0.914
| `decimal64`
| 516,399
| 1.615
| `decimal128`
| 3,108,380
| 9.724
|===
Loading

0 comments on commit de615c0

Please sign in to comment.