Skip to content

Commit fa9b52e

Browse files
authored
Merge pull request #22508 from palimondo/against-the-dark
[benchmark] Janitor Duty: Troublemaker Legacy
2 parents 80b9517 + c8d59b8 commit fa9b52e

8 files changed

+219
-114
lines changed

benchmark/single-source/Fibonacci.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import TestsUtils
1515
public let Fibonacci = BenchmarkInfo(
1616
name: "Fibonacci",
1717
runFunction: run_Fibonacci,
18-
tags: [.unstable, .algorithm])
18+
tags: [.algorithm])
1919

2020
func fibonacci(_ n: Int) -> Int {
21-
if (n < 2) { return 1 }
21+
if (n <= 2) { return 1 }
2222
return fibonacci(n - 2) + fibonacci(n - 1)
2323
}
2424

@@ -28,14 +28,14 @@ func Fibonacci(_ n: Int) -> Int {
2828
// at compile time.
2929
if False() { return 0 }
3030

31-
if (n < 2) { return 1 }
31+
if (n <= 2) { return 1 }
3232
return fibonacci(n - 2) + fibonacci(n - 1)
3333
}
3434

3535
@inline(never)
3636
public func run_Fibonacci(_ N: Int) {
37-
let n = 32
38-
let ref_result = 3524578
37+
let n = 24
38+
let ref_result = 46368
3939
var result = 0
4040
for _ in 1...N {
4141
result = Fibonacci(n)

benchmark/single-source/FloatingPointPrinting.swift

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,47 +19,56 @@ public let FloatingPointPrinting = [
1919
BenchmarkInfo(
2020
name: "FloatingPointPrinting_Float_description_small",
2121
runFunction: run_FloatingPointPrinting_Float_description_small,
22-
tags: [.validation, .api, .runtime, .String]),
22+
tags: [.validation, .api, .runtime, .String],
23+
legacyFactor: 108),
2324

2425
BenchmarkInfo(
2526
name: "FloatingPointPrinting_Double_description_small",
2627
runFunction: run_FloatingPointPrinting_Double_description_small,
27-
tags: [.validation, .api, .runtime, .String]),
28+
tags: [.validation, .api, .runtime, .String],
29+
legacyFactor: 100),
2830

2931
BenchmarkInfo(
3032
name: "FloatingPointPrinting_Float80_description_small",
3133
runFunction: run_FloatingPointPrinting_Float80_description_small,
32-
tags: [.validation, .api, .runtime, .String]),
34+
tags: [.validation, .api, .runtime, .String],
35+
legacyFactor: 108),
3336

3437
BenchmarkInfo(
3538
name: "FloatingPointPrinting_Float_description_uniform",
3639
runFunction: run_FloatingPointPrinting_Float_description_uniform,
37-
tags: [.validation, .api, .runtime, .String]),
40+
tags: [.validation, .api, .runtime, .String],
41+
legacyFactor: 100),
3842

3943
BenchmarkInfo(
4044
name: "FloatingPointPrinting_Double_description_uniform",
4145
runFunction: run_FloatingPointPrinting_Double_description_uniform,
42-
tags: [.validation, .api, .runtime, .String]),
46+
tags: [.validation, .api, .runtime, .String],
47+
legacyFactor: 100),
4348

4449
BenchmarkInfo(
4550
name: "FloatingPointPrinting_Float80_description_uniform",
4651
runFunction: run_FloatingPointPrinting_Float80_description_uniform,
47-
tags: [.validation, .api, .runtime, .String]),
52+
tags: [.validation, .api, .runtime, .String],
53+
legacyFactor: 100),
4854

4955
BenchmarkInfo(
5056
name: "FloatingPointPrinting_Float_interpolated",
5157
runFunction: run_FloatingPointPrinting_Float_interpolated,
52-
tags: [.validation, .api, .runtime, .String]),
58+
tags: [.validation, .api, .runtime, .String],
59+
legacyFactor: 200),
5360

5461
BenchmarkInfo(
5562
name: "FloatingPointPrinting_Double_interpolated",
5663
runFunction: run_FloatingPointPrinting_Double_interpolated,
57-
tags: [.validation, .api, .runtime, .String]),
64+
tags: [.validation, .api, .runtime, .String],
65+
legacyFactor: 200),
5866

5967
BenchmarkInfo(
6068
name: "FloatingPointPrinting_Float80_interpolated",
6169
runFunction: run_FloatingPointPrinting_Float80_interpolated,
62-
tags: [.validation, .api, .runtime, .String])
70+
tags: [.validation, .api, .runtime, .String],
71+
legacyFactor: 200)
6372
]
6473

6574
// Generate descriptions for 100,000 values around 1.0.
@@ -75,7 +84,7 @@ public let FloatingPointPrinting = [
7584

7685
@inline(never)
7786
public func run_FloatingPointPrinting_Float_description_small(_ N: Int) {
78-
let count = 100_000
87+
let count = 1_000
7988
for _ in 0..<N {
8089
for i in 1...count {
8190
let f = Float(i) / 101.0
@@ -86,7 +95,7 @@ public func run_FloatingPointPrinting_Float_description_small(_ N: Int) {
8695

8796
@inline(never)
8897
public func run_FloatingPointPrinting_Double_description_small(_ N: Int) {
89-
let count = 100_000
98+
let count = 1_000
9099
for _ in 0..<N {
91100
for i in 1...count {
92101
let f = Double(i) / 101.0
@@ -101,7 +110,7 @@ public func run_FloatingPointPrinting_Float80_description_small(_ N: Int) {
101110
// On Darwin, long double is Float80 on x86, and Double otherwise.
102111
// On Linux, Float80 is at aleast available on x86.
103112
#if arch(x86_64) || arch(i386)
104-
let count = 100_000
113+
let count = 1_000
105114
for _ in 0..<N {
106115
for i in 1...count {
107116
let f = Float80(i) / 101.0
@@ -117,7 +126,7 @@ public func run_FloatingPointPrinting_Float80_description_small(_ N: Int) {
117126

118127
@inline(never)
119128
public func run_FloatingPointPrinting_Float_description_uniform(_ N: Int) {
120-
let count = 100_000
129+
let count = 1_000
121130
let step = UInt32.max / UInt32(count)
122131
for _ in 0..<N {
123132
for i in 0..<count {
@@ -130,7 +139,7 @@ public func run_FloatingPointPrinting_Float_description_uniform(_ N: Int) {
130139

131140
@inline(never)
132141
public func run_FloatingPointPrinting_Double_description_uniform(_ N: Int) {
133-
let count = 100_000
142+
let count = 1_000
134143
let step = UInt64.max / UInt64(count)
135144
for _ in 0..<N {
136145
for i in 0..<count {
@@ -147,7 +156,7 @@ public func run_FloatingPointPrinting_Float80_description_uniform(_ N: Int) {
147156
// On Darwin, long double is Float80 on x86, and Double otherwise.
148157
// On Linux, Float80 is at aleast available on x86.
149158
#if arch(x86_64) || arch(i386)
150-
let count = 100_000
159+
let count = 1_000
151160
let step = UInt64.max / UInt64(count)
152161
for _ in 0..<N {
153162
for i in 0..<count {
@@ -167,7 +176,7 @@ public func run_FloatingPointPrinting_Float80_description_uniform(_ N: Int) {
167176

168177
@inline(never)
169178
public func run_FloatingPointPrinting_Float_interpolated(_ N: Int) {
170-
let count = 100_000
179+
let count = 500
171180
let step = UInt32.max / UInt32(count)
172181
for _ in 0..<N {
173182
for i in 0..<count {
@@ -180,7 +189,7 @@ public func run_FloatingPointPrinting_Float_interpolated(_ N: Int) {
180189

181190
@inline(never)
182191
public func run_FloatingPointPrinting_Double_interpolated(_ N: Int) {
183-
let count = 100_000
192+
let count = 500
184193
let step = UInt64.max / UInt64(count)
185194
for _ in 0..<N {
186195
for i in 0..<count {
@@ -197,7 +206,7 @@ public func run_FloatingPointPrinting_Float80_interpolated(_ N: Int) {
197206
// On Darwin, long double is Float80 on x86, and Double otherwise.
198207
// On Linux, Float80 is at aleast available on x86.
199208
#if arch(x86_64) || arch(i386)
200-
let count = 100_000
209+
let count = 500
201210
let step = UInt64.max / UInt64(count)
202211
for _ in 0..<N {
203212
for i in 0..<count {
@@ -210,4 +219,3 @@ public func run_FloatingPointPrinting_Float80_interpolated(_ N: Int) {
210219
#endif // x86
211220
#endif // Darwin/Linux
212221
}
213-

0 commit comments

Comments
 (0)