diff --git a/benchmark/single-source/CString.swift b/benchmark/single-source/CString.swift index 0f242e88edaef..b64a915c631b8 100644 --- a/benchmark/single-source/CString.swift +++ b/benchmark/single-source/CString.swift @@ -65,7 +65,7 @@ let reference = 517492 @inline(never) public func run_CStringShortAscii(_ N: Int) { - + func DoOneIter(_ arr: [String]) -> Int { var r = 0 for n in arr { @@ -79,11 +79,10 @@ public func run_CStringShortAscii(_ N: Int) { var res = Int.max for _ in 1...100*N { - let strings = input.map { + let strings = input.map { $0.withCString(String.init(cString:)) } res = res & DoOneIter(strings) } - assert(res == reference) + CheckResults(res == reference) } - diff --git a/benchmark/single-source/ObjectAllocation.swift b/benchmark/single-source/ObjectAllocation.swift index f4ee428d46c11..5333a589afbe2 100644 --- a/benchmark/single-source/ObjectAllocation.swift +++ b/benchmark/single-source/ObjectAllocation.swift @@ -128,4 +128,3 @@ public func run_ObjectAllocation(_ N: Int) { CheckResults(ListResult == 48375) CheckResults(ArrayResult == 3000) } - diff --git a/benchmark/single-source/SortLettersInPlace.swift b/benchmark/single-source/SortLettersInPlace.swift index b48e521fc8850..2649f02262f66 100644 --- a/benchmark/single-source/SortLettersInPlace.swift +++ b/benchmark/single-source/SortLettersInPlace.swift @@ -42,4 +42,3 @@ public func run_SortLettersInPlace(_ N: Int) { CheckResults(letters[0].value <= letters[letters.count/2].value) } } - diff --git a/benchmark/utils/TestsUtils.swift b/benchmark/utils/TestsUtils.swift index 061ead8a0c968..db581344a4b26 100644 --- a/benchmark/utils/TestsUtils.swift +++ b/benchmark/utils/TestsUtils.swift @@ -49,11 +49,31 @@ public func Random() -> Int64 { return lfsrRandomGenerator.randInt() } -public func CheckResults(_ resultsMatch: Bool, _ message: @autoclosure () -> String) { - guard resultsMatch else { - print(message()) - abort() - } +@inline(__always) +public func CheckResults( + _ resultsMatch: Bool, + file: StaticString = #file, + function: StaticString = #function, + line: Int = #line + ) { + guard _fastPath(resultsMatch) else { + print("Incorrect result in \(function), \(file):\(line)") + abort() + } +} + +// Due to potential overhead of passing closures around on the +// performance measurements, this version is now deprecated +@available(*, deprecated, + message: "For debugging test failures only! Use the version without message.") +public func CheckResults( + _ resultsMatch: Bool, + _ message: @autoclosure () -> String + ) { + guard resultsMatch else { + print(message()) + abort() + } } public func False() -> Bool { return false } @@ -71,9 +91,3 @@ public func someProtocolFactory() -> SomeProtocol { return MyStruct() } // which are using it. public func blackHole(_ x: T) { } - -@inline(__always) -public func CheckResults(_ resultsMatch: Bool) { - guard _fastPath(resultsMatch) else { abort() } -} -