Skip to content

Commit 593155f

Browse files
committedMar 6, 2017
Make benchmarks compile and run on Linux
1 parent 4def042 commit 593155f

11 files changed

+232
-6
lines changed
 

Diff for: ‎benchmark/single-source/DictionaryBridge.swift

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import Foundation
1717
import TestsUtils
1818

19+
#if _runtime(_ObjC)
1920
class Thing : NSObject {
2021

2122
required override init() {
@@ -50,10 +51,13 @@ class Stuff {
5051

5152
}
5253
}
54+
#endif
5355

5456
@inline(never)
5557
public func run_DictionaryBridge(_ N: Int) {
58+
#if _runtime(_ObjC)
5659
for _ in 1...100*N {
5760
_ = Stuff()
5861
}
62+
#endif
5963
}

Diff for: ‎benchmark/single-source/MapReduce.swift

+4
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public func run_MapReduceShortString(_ N: Int) {
133133

134134
@inline(never)
135135
public func run_MapReduceClass(_ N: Int) {
136+
#if _runtime(_ObjC)
136137
let numbers = (0..<1000).map { NSDecimalNumber(value: $0) }
137138

138139
var c = 0
@@ -141,10 +142,12 @@ public func run_MapReduceClass(_ N: Int) {
141142
c += mapped.reduce(0, &+)
142143
}
143144
CheckResults(c != 0, "IncorrectResults in MapReduce")
145+
#endif
144146
}
145147

146148
@inline(never)
147149
public func run_MapReduceClassShort(_ N: Int) {
150+
#if _runtime(_ObjC)
148151
let numbers = (0..<10).map { NSDecimalNumber(value: $0) }
149152

150153
var c = 0
@@ -153,5 +156,6 @@ public func run_MapReduceClassShort(_ N: Int) {
153156
c += mapped.reduce(0, &+)
154157
}
155158
CheckResults(c != 0, "IncorrectResults in MapReduce")
159+
#endif
156160
}
157161

Diff for: ‎benchmark/single-source/NSDictionaryCastToSwift.swift

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import TestsUtils
2020

2121
@inline(never)
2222
public func run_NSDictionaryCastToSwift(_ N: Int) {
23+
#if _runtime(_ObjC)
2324
let NSDict = NSDictionary()
2425
var swiftDict = [String: NSObject]()
2526
for _ in 1...10000*N {
@@ -31,4 +32,5 @@ public func run_NSDictionaryCastToSwift(_ N: Int) {
3132
CheckResults(swiftDict.isEmpty,
3233
"Incorrect result in swiftDict.isEmpty: " +
3334
"\(swiftDict.isEmpty) != true\n")
35+
#endif
3436
}

Diff for: ‎benchmark/single-source/NSStringConversion.swift

+2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ import TestsUtils
1515
import Foundation
1616

1717
public func run_NSStringConversion(_ N: Int) {
18+
#if _runtime(_ObjC)
1819
let test:NSString = NSString(cString: "test", encoding: String.Encoding.ascii.rawValue)!
1920
for _ in 1...N * 10000 {
2021
_ = test as String
2122
}
23+
#endif
2224
}

0 commit comments

Comments
 (0)
Please sign in to comment.