Skip to content

Commit de615c0

Browse files
authored
Merge pull request #510 from cppalliance/More_benchmarks
2 parents e72a5fd + 4bb8f5b commit de615c0

File tree

2 files changed

+543
-90
lines changed

2 files changed

+543
-90
lines changed

doc/decimal/benchmarks.adoc

Lines changed: 246 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,36 @@ An example on Linux with b2: `../../../b2 cxxstd=20 toolset=gcc-13 define=BOOST_
2222

2323
== Comparisons
2424

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

2728
=== M1 macOS Results
2829

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

3132
|===
32-
| Type | Runtime (ms) | Ratio to `double`
33+
| Type | Runtime (us) | Ratio to `double`
3334
| `float`
34-
| 8
35-
| 1.333
35+
| 9032
36+
| 1.589
3637
| `double`
37-
| 6
38+
| 5684
3839
| 1.000
3940
| `decimal32`
40-
| 380
41-
| 63.333
41+
| 285,453
42+
| 50.2204
4243
| `decimal64`
43-
| 408
44-
| 608.000
44+
| 352,644
45+
| 62.042
4546
| `decimal128`
46-
| 14641
47-
| 2440.170
47+
| 15,355,817
48+
| 2701.590
4849
|===
4950

5051
== Basic Operations
5152

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

5456
=== M1 macOS Results
5557

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

6062
|===
61-
| Type | Runtime (ms) | Ratio to `double`
63+
| Type | Runtime (us) | Ratio to `double`
6264
| `float`
63-
| 6
64-
| 1.500
65+
| 1641
66+
| 0.965
6567
| `double`
66-
| 4
68+
| 1708
6769
| 1.000
6870
| `decimal32`
69-
| 361
70-
| 90.250
71+
| 378,252
72+
| 221.459
7173
| `decimal64`
72-
| 568
73-
| 142.000
74+
| 589,313
75+
| 345.031
7476
| `decimal128`
75-
| 13428
76-
| 3357.000
77+
| 13,829,995
78+
| 8097.190
7779
|===
7880

7981
==== Subtraction
8082

8183
|===
82-
| Type | Runtime (ms) | Ratio to `double`
84+
| Type | Runtime (us) | Ratio to `double`
8385
| `float`
84-
| 3
85-
| 3.000
86+
| 3633
87+
| 2.221
8688
| `double`
87-
| 1
89+
| 1636
8890
| 1.000
8991
| `decimal32`
90-
| 307
91-
| 307.000
92+
| 307,765
93+
| 188.120
9294
| `decimal64`
93-
| 465
94-
| 465.000
95+
| 461,442
96+
| 282.055
9597
| `decimal128`
96-
| 11444
97-
| 11444.000
98+
| 11,449,306
99+
| 6998.350
98100
|===
99101

100102
==== Multiplication
101103

102104
|===
103-
| Type | Runtime (ms) | Ratio to `double`
105+
| Type | Runtime (us) | Ratio to `double`
104106
| `float`
105-
| 1
106-
| 0.333
107+
| 1678
108+
| 0.523
107109
| `double`
108-
| 3
110+
| 3209
109111
| 1.000
110112
| `decimal32`
111-
| 311
112-
| 103.667
113+
| 310,543
114+
| 96.773
113115
| `decimal64`
114-
| 569
115-
| 189.667
116+
| 570,938
117+
| 177.918
116118
| `decimal128`
117-
| 9430
118-
| 3143.330
119+
| 9,434,297
120+
| 2939.95
119121
|===
120122

121123
==== Division
122124

123125
|===
124-
| Type | Runtime (ms) | Ratio to `double`
126+
| Type | Runtime (us) | Ratio to `double`
125127
| `float`
126-
| 2
127-
| 0.667
128+
| 2019
129+
| 0.565
128130
| `double`
129-
| 3
131+
| 3572
130132
| 1.000
131133
| `decimal32`
132-
| 319
133-
| 106.333
134+
| 322,116
135+
| 90.178
134136
| `decimal64`
135-
| 395
136-
| 131.667
137+
| 734,173
138+
| 205.536
137139
| `decimal128`
138-
| 14781
139-
| 4927.000
140+
| 14,592,284
141+
| 4085.19
142+
|===
143+
144+
== Selected Special Functions
145+
146+
The benchmark for these operations generates a random vector containing 2,000,000 elements and does operations `+`, `-`, `*`, `/` between `vec[i] and vec[i + 1]`.
147+
This is repeated 5 times to generate stable results.
148+
149+
=== M1 macOS Results
150+
151+
Run using a Macbook pro with M1 pro chipset running macOS Sonoma 14.4.1 and homebrew Clang 18.1.4
152+
153+
==== SQRT
154+
155+
|===
156+
| Type | Runtime (us) | Ratio to `double`
157+
| `float`
158+
| 1904
159+
| 0.565
160+
| `double`
161+
| 3746
162+
| 1.000
163+
| `decimal32`
164+
| 5,050,241
165+
| 1341.72
166+
| `decimal64`
167+
| 12,084,821
168+
| 3210.630
169+
| `decimal128`
170+
| 275,779,340
171+
| 73267.60
172+
|===
173+
174+
== `<charconv>`
175+
176+
For all the following the results compare against https://github.com/boostorg/charconv[boost.charconv] for 10'000'000 conversions.
177+
178+
=== `from_chars` general
179+
180+
==== M1 macOS Results
181+
182+
Run using a Macbook pro with M1 pro chipset running macOS Sonoma 14.4.1 and homebrew Clang 18.1.4
183+
184+
|===
185+
| Type | Runtime (us) | Ratio to `double`
186+
| `float`
187+
| 235,816
188+
| 0.953
189+
| `double`
190+
| 247,307
191+
| 1.000
192+
| `decimal32`
193+
| 366,682
194+
| 1.483
195+
| `decimal64`
196+
| 485,965
197+
| 1.965
198+
// Decimal128 was two orders of magnitude faster. I expect an issue
199+
//| `decimal128`
200+
//| 275,779,340
201+
//| 73267.60
202+
|===
203+
204+
NOTE: `decimal128` is currently absent due to results showing it is 2 orders of magnitude faster than the others.
205+
This should not be the case so will be investigated.
206+
207+
=== `from_chars` scientific
208+
209+
==== M1 macOS Results
210+
211+
Run using a Macbook pro with M1 pro chipset running macOS Sonoma 14.4.1 and homebrew Clang 18.1.4
212+
213+
|===
214+
| Type | Runtime (us) | Ratio to `double`
215+
| `float`
216+
| 241,893
217+
| 0.975
218+
| `double`
219+
| 247,975
220+
| 1.000
221+
| `decimal32`
222+
| 358,189
223+
| 1.444
224+
| `decimal64`
225+
| 477,574
226+
| 1.926
227+
// Decimal128 was two orders of magnitude faster. I expect an issue
228+
//| `decimal128`
229+
//| 275,779,340
230+
//| 73267.60
231+
|===
232+
233+
NOTE: `decimal128` is currently absent due to results showing it is 2 orders of magnitude faster than the others.
234+
This should not be the case so will be investigated.
235+
236+
=== `to_chars` general shortest representation
237+
238+
==== M1 macOS Results
239+
240+
Run using a Macbook pro with M1 pro chipset running macOS Sonoma 14.4.1 and homebrew Clang 18.1.4
241+
242+
|===
243+
| Type | Runtime (us) | Ratio to `double`
244+
| `float`
245+
| 316,300
246+
| 1.040
247+
| `double`
248+
| 304,272
249+
| 1.000
250+
| `decimal32`
251+
| 406,053
252+
| 1.335
253+
| `decimal64`
254+
| 678,451
255+
| 2.230
256+
| `decimal128`
257+
| 6,309,346
258+
| 20.736
259+
|===
260+
261+
=== `to_chars` general 6-digits of precision
262+
263+
==== M1 macOS Results
264+
265+
Run using a Macbook pro with M1 pro chipset running macOS Sonoma 14.4.1 and homebrew Clang 18.1.4
266+
267+
|===
268+
| Type | Runtime (us) | Ratio to `double`
269+
| `float`
270+
| 323,867
271+
| 0.967
272+
| `double`
273+
| 334,989
274+
| 1.000
275+
| `decimal32`
276+
| 409,608
277+
| 1.223
278+
| `decimal64`
279+
| 702,339
280+
| 2.097
281+
| `decimal128`
282+
| 6,305,521
283+
| 18.823
284+
|===
285+
286+
=== `to_chars` scientific shortest representation
287+
288+
==== M1 macOS Results
289+
290+
Run using a Macbook pro with M1 pro chipset running macOS Sonoma 14.4.1 and homebrew Clang 18.1.4
291+
292+
|===
293+
| Type | Runtime (us) | Ratio to `double`
294+
| `float`
295+
| 286,330
296+
| 1.011
297+
| `double`
298+
| 283,287
299+
| 1.000
300+
| `decimal32`
301+
| 290,117
302+
| 1.024
303+
| `decimal64`
304+
| 499,637
305+
| 1.764
306+
| `decimal128`
307+
| 3,096,910
308+
| 10.932
309+
|===
310+
311+
=== `to_chars` scientific 6-digits of precision
312+
313+
==== M1 macOS Results
314+
315+
Run using a Macbook pro with M1 pro chipset running macOS Sonoma 14.4.1 and homebrew Clang 18.1.4
316+
317+
|===
318+
| Type | Runtime (us) | Ratio to `double`
319+
| `float`
320+
| 258,710
321+
| 0.809
322+
| `double`
323+
| 319,676
324+
| 1.000
325+
| `decimal32`
326+
| 292,250
327+
| 0.914
328+
| `decimal64`
329+
| 516,399
330+
| 1.615
331+
| `decimal128`
332+
| 3,108,380
333+
| 9.724
140334
|===

0 commit comments

Comments
 (0)