Skip to content

Commit 1dd9d61

Browse files
author
Max Moiseev
committed
Move all benchmarks to use registerBenchmark and BenchmarkInfo
1 parent 86eeb54 commit 1dd9d61

File tree

107 files changed

+1663
-553
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+1663
-553
lines changed

benchmark/multi-source/PrimsSplit/main.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212

1313
import TestsUtils
1414

15+
public let PrimsSplit = BenchmarkInfo(
16+
name: "PrimsSplit",
17+
runFunction: run_PrimsSplit,
18+
tags: [.validation, .algorithm])
19+
1520
@inline(never)
1621
public func run_PrimsSplit(_ N: Int) {
1722
for _ in 1...5*N {

benchmark/single-source/Ackermann.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
// for performance measuring.
1515
import TestsUtils
1616

17+
public let Ackermann = BenchmarkInfo(
18+
name: "Ackermann",
19+
runFunction: run_Ackermann,
20+
tags: [.unstable, .algorithm])
21+
1722
func ackermann(_ M: Int, _ N : Int) -> Int {
1823
if (M == 0) { return N + 1 }
1924
if (N == 0) { return ackermann(M - 1, 1) }

benchmark/single-source/AngryPhonebook.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
import TestsUtils
1616
import Foundation
1717

18+
public let AngryPhonebook = BenchmarkInfo(
19+
name: "AngryPhonebook",
20+
runFunction: run_AngryPhonebook,
21+
tags: [.validation, .api, .String])
22+
1823
var words = [
1924
"James", "John", "Robert", "Michael", "William", "David", "Richard", "Joseph",
2025
"Charles", "Thomas", "Christopher", "Daniel", "Matthew", "Donald", "Anthony",

benchmark/single-source/Array2D.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
import TestsUtils
14+
15+
public let Array2D = BenchmarkInfo(
16+
name: "Array2D",
17+
runFunction: run_Array2D,
18+
tags: [.validation, .api, .Array])
19+
1320
@inline(never)
1421
public func run_Array2D(_ N: Int) {
1522
var A: [[Int]] = []

benchmark/single-source/ArrayAppend.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,28 @@
1414

1515
import TestsUtils
1616

17+
public let ArrayAppend = [
18+
BenchmarkInfo(name: "ArrayAppend", runFunction: run_ArrayAppend, tags: [.validation, .api, .Array]),
19+
BenchmarkInfo(name: "ArrayAppendArrayOfInt", runFunction: run_ArrayAppendArrayOfInt, tags: [.validation, .api, .Array]),
20+
BenchmarkInfo(name: "ArrayAppendAscii", runFunction: run_ArrayAppendAscii, tags: [.validation, .api, .Array]),
21+
BenchmarkInfo(name: "ArrayAppendFromGeneric", runFunction: run_ArrayAppendFromGeneric, tags: [.validation, .api, .Array]),
22+
BenchmarkInfo(name: "ArrayAppendGenericStructs", runFunction: run_ArrayAppendGenericStructs, tags: [.validation, .api, .Array]),
23+
BenchmarkInfo(name: "ArrayAppendLatin1", runFunction: run_ArrayAppendLatin1, tags: [.validation, .api, .Array]),
24+
BenchmarkInfo(name: "ArrayAppendLazyMap", runFunction: run_ArrayAppendLazyMap, tags: [.validation, .api, .Array]),
25+
BenchmarkInfo(name: "ArrayAppendOptionals", runFunction: run_ArrayAppendOptionals, tags: [.validation, .api, .Array]),
26+
BenchmarkInfo(name: "ArrayAppendRepeatCol", runFunction: run_ArrayAppendRepeatCol, tags: [.validation, .api, .Array]),
27+
BenchmarkInfo(name: "ArrayAppendReserved", runFunction: run_ArrayAppendReserved, tags: [.validation, .api, .Array]),
28+
BenchmarkInfo(name: "ArrayAppendSequence", runFunction: run_ArrayAppendSequence, tags: [.validation, .api, .Array]),
29+
BenchmarkInfo(name: "ArrayAppendStrings", runFunction: run_ArrayAppendStrings, tags: [.validation, .api, .Array]),
30+
BenchmarkInfo(name: "ArrayAppendToFromGeneric", runFunction: run_ArrayAppendToFromGeneric, tags: [.validation, .api, .Array]),
31+
BenchmarkInfo(name: "ArrayAppendToGeneric", runFunction: run_ArrayAppendToGeneric, tags: [.validation, .api, .Array]),
32+
BenchmarkInfo(name: "ArrayAppendUTF16", runFunction: run_ArrayAppendUTF16, tags: [.validation, .api, .Array]),
33+
BenchmarkInfo(name: "ArrayPlusEqualArrayOfInt", runFunction: run_ArrayPlusEqualArrayOfInt, tags: [.validation, .api, .Array]),
34+
BenchmarkInfo(name: "ArrayPlusEqualFiveElementCollection", runFunction: run_ArrayPlusEqualFiveElementCollection, tags: [.validation, .api, .Array]),
35+
BenchmarkInfo(name: "ArrayPlusEqualSingleElementCollection", runFunction: run_ArrayPlusEqualSingleElementCollection, tags: [.validation, .api, .Array]),
36+
BenchmarkInfo(name: "ArrayPlusEqualThreeElements", runFunction: run_ArrayPlusEqualThreeElements, tags: [.validation, .api, .Array]),
37+
]
38+
1739
// Append single element
1840
@inline(never)
1941
public func run_ArrayAppend(_ N: Int) {

benchmark/single-source/ArrayInClass.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
import TestsUtils
14+
public let ArrayInClass = BenchmarkInfo(
15+
name: "ArrayInClass",
16+
runFunction: run_ArrayInClass,
17+
tags: [.validation, .api, .Array])
18+
1319
class ArrayContainer {
1420
final var arr : [Int]
1521

benchmark/single-source/ArrayLiteral.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
// It is reported to be slow: <rdar://problem/17297449>
1616
import TestsUtils
1717

18+
public let ArrayLiteral = [
19+
BenchmarkInfo(name: "ArrayLiteral", runFunction: run_ArrayLiteral, tags: [.validation, .api, .Array]),
20+
BenchmarkInfo(name: "ArrayValueProp", runFunction: run_ArrayValueProp, tags: [.validation, .api, .Array]),
21+
BenchmarkInfo(name: "ArrayValueProp2", runFunction: run_ArrayValueProp2, tags: [.validation, .api, .Array]),
22+
BenchmarkInfo(name: "ArrayValueProp3", runFunction: run_ArrayValueProp3, tags: [.validation, .api, .Array]),
23+
BenchmarkInfo(name: "ArrayValueProp4", runFunction: run_ArrayValueProp4, tags: [.validation, .api, .Array]),
24+
]
25+
1826
@inline(never)
1927
func makeArray() -> [Int] {
2028
return [1,2,3]

benchmark/single-source/ArrayOfGenericPOD.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
// For comparison, we always create three arrays of 200,000 words.
1919
// An integer enum takes two words.
2020

21+
import TestsUtils
22+
23+
public let ArrayOfGenericPOD = BenchmarkInfo(
24+
name: "ArrayOfGenericPOD",
25+
runFunction: run_ArrayOfGenericPOD,
26+
tags: [.validation, .api, .Array])
27+
2128
class RefArray<T> {
2229
var array: [T]
2330

benchmark/single-source/ArrayOfGenericRef.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
//
1616
// For comparison, we always create three arrays of 10,000 words.
1717

18+
import TestsUtils
19+
20+
public let ArrayOfGenericRef = BenchmarkInfo(
21+
name: "ArrayOfGenericRef",
22+
runFunction: run_ArrayOfGenericRef,
23+
tags: [.validation, .api, .Array])
24+
1825
protocol Constructible {
1926
associatedtype Element
2027
init(e:Element)

benchmark/single-source/ArrayOfPOD.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
//
1717
// For comparison, we always create three arrays of 200,000 words.
1818

19+
import TestsUtils
20+
21+
public let ArrayOfPOD = BenchmarkInfo(
22+
name: "ArrayOfPOD",
23+
runFunction: run_ArrayOfPOD,
24+
tags: [.validation, .api, .Array])
25+
1926
class RefArray<T> {
2027
var array : [T]
2128

benchmark/single-source/ArrayOfRef.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
//
1717
// For comparison, we always create four arrays of 10,000 words.
1818

19+
import TestsUtils
20+
21+
public let ArrayOfRef = BenchmarkInfo(
22+
name: "ArrayOfRef",
23+
runFunction: run_ArrayOfRef,
24+
tags: [.validation, .api, .Array])
25+
1926
protocol Constructible {
2027
associatedtype Element
2128
init(e:Element)

benchmark/single-source/ArraySubscript.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
// This test checks the performance of modifying an array element.
1414
import TestsUtils
1515

16+
public let ArraySubscript = BenchmarkInfo(
17+
name: "ArraySubscript",
18+
runFunction: run_ArraySubscript,
19+
tags: [.validation, .api, .Array])
20+
1621
@inline(never)
1722
public func run_ArraySubscript(_ N: Int) {
1823
SRand()

benchmark/single-source/BitCount.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
import Foundation
1717
import TestsUtils
1818

19+
public let BitCount = BenchmarkInfo(
20+
name: "BitCount",
21+
runFunction: run_BitCount,
22+
tags: [.validation, .algorithm])
23+
1924
func countBitSet(_ num: Int) -> Int {
2025
let bits = MemoryLayout<Int>.size * 8
2126
var cnt: Int = 0

benchmark/single-source/ByteSwap.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
import Foundation
1717
import TestsUtils
1818

19+
public let ByteSwap = BenchmarkInfo(
20+
name: "ByteSwap",
21+
runFunction: run_ByteSwap,
22+
tags: [.validation, .algorithm])
23+
1924
// a naive O(n) implementation of byteswap.
2025
@inline(never)
2126
func byteswap_n(_ a: UInt64) -> UInt64 {

benchmark/single-source/CString.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ import Glibc
1717
import Darwin
1818
#endif
1919

20+
public let CString = [
21+
BenchmarkInfo(name: "CStringLongAscii", runFunction: run_CStringLongAscii, tags: [.validation, .api, .String, .bridging]),
22+
BenchmarkInfo(name: "CStringLongNonAscii", runFunction: run_CStringLongNonAscii, tags: [.validation, .api, .String, .bridging]),
23+
BenchmarkInfo(name: "CStringShortAscii", runFunction: run_CStringShortAscii, tags: [.validation, .api, .String, .bridging]),
24+
BenchmarkInfo(name: "StringWithCString", runFunction: run_StringWithCString, tags: [.validation, .api, .String, .bridging]),
25+
]
26+
2027
let ascii = "Swift is a multi-paradigm, compiled programming language created for iOS, OS X, watchOS, tvOS and Linux development by Apple Inc. Swift is designed to work with Apple's Cocoa and Cocoa Touch frameworks and the large body of existing Objective-C code written for Apple products. Swift is intended to be more resilient to erroneous code (\"safer\") than Objective-C and also more concise. It is built with the LLVM compiler framework included in Xcode 6 and later and uses the Objective-C runtime, which allows C, Objective-C, C++ and Swift code to run within a single program."
2128
let japanese = "日本語(にほんご、にっぽんご)は、主に日本国内や日本人同士の間で使われている言語である。"
2229

benchmark/single-source/Calculator.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
import TestsUtils
1414
import Foundation
1515

16+
public let Calculator = BenchmarkInfo(
17+
name: "Calculator",
18+
runFunction: run_Calculator,
19+
tags: [.validation])
20+
1621
@inline(never)
1722
func my_atoi_impl(_ input : String) -> Int {
1823
switch input {

benchmark/single-source/CaptureProp.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
import TestsUtils
14+
15+
public let CaptureProp = BenchmarkInfo(
16+
name: "CaptureProp",
17+
runFunction: run_CaptureProp,
18+
tags: [.validation, .api, .refcount])
19+
1320
func sum(_ x:Int, y:Int) -> Int {
1421
return x + y
1522
}

benchmark/single-source/CharacterLiteralsLarge.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
// and retain a StringBuffer.
1616
import TestsUtils
1717

18+
public let CharacterLiteralsLarge = BenchmarkInfo(
19+
name: "CharacterLiteralsLarge",
20+
runFunction: run_CharacterLiteralsLarge,
21+
tags: [.validation, .api, .String])
22+
1823
@inline(never)
1924
func makeCharacter_UTF8Length9() -> Character {
2025
return "a\u{0300}\u{0301}\u{0302}\u{0303}"

benchmark/single-source/CharacterLiteralsSmall.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
// represented as a packed integer.
1616
import TestsUtils
1717

18+
public let CharacterLiteralsSmall = BenchmarkInfo(
19+
name: "CharacterLiteralsSmall",
20+
runFunction: run_CharacterLiteralsSmall,
21+
tags: [.validation, .api, .String])
22+
1823
@inline(never)
1924
func makeCharacter_UTF8Length1() -> Character {
2025
return "a"

benchmark/single-source/Chars.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
// This test tests the performance of ASCII Character comparison.
1414
import TestsUtils
1515

16+
public let Chars = BenchmarkInfo(
17+
name: "Chars",
18+
runFunction: run_Chars,
19+
tags: [.validation, .api, .String])
20+
1621
@inline(never)
1722
public func run_Chars(_ N: Int) {
1823
// Permute some characters.

benchmark/single-source/ClassArrayGetter.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
import TestsUtils
14+
15+
public let ClassArrayGetter = BenchmarkInfo(
16+
name: "ClassArrayGetter",
17+
runFunction: run_ClassArrayGetter,
18+
tags: [.validation, .api, .Array])
19+
1320
class Box {
1421
var v: Int
1522
init(v: Int) { self.v = v }

benchmark/single-source/DeadArray.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
// rdar://problem/20980377
1414
import TestsUtils
1515

16+
public let DeadArray = BenchmarkInfo(
17+
name: "DeadArray",
18+
runFunction: run_DeadArray,
19+
tags: [.regression])
20+
1621
@inline(__always)
1722
func debug(_ m:String) {}
1823

benchmark/single-source/DictTest.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212

1313
import TestsUtils
1414

15+
16+
public let Dictionary = [
17+
BenchmarkInfo(name: "Dictionary", runFunction: run_Dictionary, tags: [.validation, .api, .Dictionary]),
18+
BenchmarkInfo(name: "DictionaryOfObjects", runFunction: run_DictionaryOfObjects, tags: [.validation, .api, .Dictionary]),
19+
]
20+
1521
@inline(never)
1622
public func run_Dictionary(scale: Int) {
1723
let Input = [

benchmark/single-source/DictTest2.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212

1313
import TestsUtils
1414

15+
public let Dictionary2 = [
16+
BenchmarkInfo(name: "Dictionary2", runFunction: run_Dictionary2, tags: [.validation, .api, .Dictionary]),
17+
BenchmarkInfo(name: "Dictionary2OfObjects", runFunction: run_Dictionary2OfObjects, tags: [.validation, .api, .Dictionary]),
18+
]
19+
1520
@inline(never)
1621
public func run_Dictionary2(_ N: Int) {
1722
let size = 500
@@ -55,6 +60,7 @@ class Box<T : Hashable> : Hashable {
5560

5661
@inline(never)
5762
public func run_Dictionary2OfObjects(_ N: Int) {
63+
5864
let size = 500
5965
let ref_result = 199
6066
var res = 0

benchmark/single-source/DictTest3.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212

1313
import TestsUtils
1414

15+
public let Dictionary3 = [
16+
BenchmarkInfo(name: "Dictionary3", runFunction: run_Dictionary3, tags: [.validation, .api, .Dictionary]),
17+
BenchmarkInfo(name: "Dictionary3OfObjects", runFunction: run_Dictionary3OfObjects, tags: [.validation, .api, .Dictionary]),
18+
]
19+
1520
@inline(never)
1621
public func run_Dictionary3(_ N: Int) {
1722
let size1 = 100

benchmark/single-source/DictionaryBridge.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
import Foundation
1717
import TestsUtils
1818

19+
public let DictionaryBridge = BenchmarkInfo(
20+
name: "DictionaryBridge",
21+
runFunction: run_DictionaryBridge,
22+
tags: [.validation, .api, .Dictionary, .bridging])
23+
1924
#if _runtime(_ObjC)
2025
class Thing : NSObject {
2126

benchmark/single-source/DictionaryGroup.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212

1313
import TestsUtils
1414

15+
public let DictionaryGroup = [
16+
BenchmarkInfo(name: "DictionaryGroup", runFunction: run_DictionaryGroup, tags: [.validation, .api, .Dictionary]),
17+
BenchmarkInfo(name: "DictionaryGroupOfObjects", runFunction: run_DictionaryGroupOfObjects, tags: [.validation, .api, .Dictionary]),
18+
]
19+
1520
let count = 10_000
1621
let result = count / 10
1722

benchmark/single-source/DictionaryLiteral.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
// rdar://problem/19804127
1515
import TestsUtils
1616

17+
public let DictionaryLiteral = BenchmarkInfo(
18+
name: "DictionaryLiteral",
19+
runFunction: run_DictionaryLiteral,
20+
tags: [.validation, .api, .Dictionary])
21+
1722
@inline(never)
1823
func makeDictionary() -> [Int: Int] {
1924
return [1: 3, 2: 2, 3: 1]

benchmark/single-source/DictionaryRemove.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
// rdar://problem/19804127
1515
import TestsUtils
1616

17+
public let DictionaryRemove = [
18+
BenchmarkInfo(name: "DictionaryRemove", runFunction: run_DictionaryRemove, tags: [.validation, .api, .Dictionary]),
19+
BenchmarkInfo(name: "DictionaryRemoveOfObjects", runFunction: run_DictionaryRemoveOfObjects, tags: [.validation, .api, .Dictionary]),
20+
]
21+
1722
@inline(never)
1823
public func run_DictionaryRemove(_ N: Int) {
1924
let size = 100

0 commit comments

Comments
 (0)