Skip to content

[benchmark] Janitor Duty: Thesaurus Heirloom #22026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a721476
[benchmark] ErrorHandling Legacy Factor
palimondo Jan 21, 2019
9cf7f7e
[benchmark] Hanoi Legacy Factor
palimondo Jan 21, 2019
f10ef5e
[benchmark] HashTest Legacy Factor
palimondo Jan 21, 2019
cccb32b
[benchmark] LazilyFiltered Legacy Factor
palimondo Jan 21, 2019
aca01c5
[benchmark] LinkedList Legacy Factor
palimondo Jan 21, 2019
3ad6ee2
[benchmark] MapReduce Legacy Factor
palimondo Jan 21, 2019
af3e9bd
[benchmark] MonteCarloE Legacy Factor
palimondo Jan 21, 2019
1e7357a
[benchmark] MonteCarloPi Legacy Factor
palimondo Jan 21, 2019
5bb1d6c
[benchmark] NibbleSort Legacy Factor
palimondo Jan 21, 2019
bbe4734
[benchmark] NopDeinit Legacy Factor
palimondo Jan 21, 2019
c9e889d
[benchmark] NSDictionaryCastToSwift Legacy Factor
palimondo Jan 21, 2019
c345104
[benchmark] ObserverClosure Legacy Factor
palimondo Jan 21, 2019
0206f96
[benchmark] ObserverForwarderStruct Legacy Factor
palimondo Jan 21, 2019
30db01c
[benchmark] ObserverPartiallyAppliedMethod LF
palimondo Jan 21, 2019
e695dad
[benchmark] ObserverUnappliedMethod Legacy Factor
palimondo Jan 21, 2019
e99673e
[benchmark] OpaqueConsumingUsers Legacy Factor
palimondo Jan 21, 2019
4a4d9b1
[benchmark] Phonebook Legacy Factor
palimondo Jan 21, 2019
c087a02
[benchmark] PointerArithmetics Legacy Factor
palimondo Jan 21, 2019
aecea33
[benchmark] PopFront Legacy Factor
palimondo Jan 21, 2019
1a72543
[benchmark] Prims Legacy Factor
palimondo Jan 21, 2019
6a657bc
[benchmark] Queue Legacy Factor
palimondo Jan 21, 2019
8cb6130
[benchmark] RandomShuffle Legacy Factor
palimondo Jan 21, 2019
91f25f6
[benchmark] RandomValues Legacy Factor
palimondo Jan 21, 2019
f477e6b
[benchmark] RangeReplaceableCollectionPlusDef. LF
palimondo Jan 21, 2019
8d00ce0
[benchmark] FilterEvenUsingReduce Legacy Factor
palimondo Jan 21, 2019
3417ee6
[benchmark] RGBHistogram Legacy Factor
palimondo Jan 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions benchmark/multi-source/PrimsSplit/Prims_main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ import TestsUtils
public let PrimsSplit = BenchmarkInfo(
name: "PrimsSplit",
runFunction: run_PrimsSplit,
tags: [.validation, .algorithm])
tags: [.validation, .algorithm],
legacyFactor: 5)

@inline(never)
public func run_PrimsSplit(_ N: Int) {
for _ in 1...5*N {
for _ in 1...N {
let nodes : [Int] = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
Expand Down
6 changes: 3 additions & 3 deletions benchmark/single-source/ErrorHandling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import TestsUtils
public let ErrorHandling = BenchmarkInfo(
name: "ErrorHandling",
runFunction: run_ErrorHandling,
tags: [.validation, .exceptions])
tags: [.validation, .exceptions],
legacyFactor: 10)

enum PizzaError : Error {
case Pepperoni, Olives, Anchovy
Expand All @@ -35,12 +36,11 @@ func doSomething() throws -> String {

@inline(never)
public func run_ErrorHandling(_ N: Int) {
for _ in 1...5000*N {
for _ in 1...500*N {
do {
_ = try doSomething()
} catch _ {

}
}
}

5 changes: 3 additions & 2 deletions benchmark/single-source/Hanoi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import TestsUtils
public let Hanoi = BenchmarkInfo(
name: "Hanoi",
runFunction: run_Hanoi,
tags: [.validation, .algorithm])
tags: [.validation, .algorithm],
legacyFactor: 10)

struct Move {
var from: String
Expand Down Expand Up @@ -46,7 +47,7 @@ class TowersOfHanoi {

@inline(never)
public func run_Hanoi(_ N: Int) {
for _ in 1...100*N {
for _ in 1...10*N {
let hanoi: TowersOfHanoi = TowersOfHanoi()
hanoi.solve(10, start: "A", auxiliary: "B", end: "C")
}
Expand Down
5 changes: 3 additions & 2 deletions benchmark/single-source/Hash.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import TestsUtils
public let HashTest = BenchmarkInfo(
name: "HashTest",
runFunction: run_HashTest,
tags: [.validation, .algorithm])
tags: [.validation, .algorithm],
legacyFactor: 10)

class Hash {
/// C'tor.
Expand Down Expand Up @@ -581,7 +582,7 @@ public func run_HashTest(_ N: Int) {
"The quick brown fox jumps over the lazy dog." : "ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c"]
let size = 50

for _ in 1...10*N {
for _ in 1...N {
// Check for precomputed values.
let MD = MD5()
for (K, V) in TestMD5 {
Expand Down
34 changes: 17 additions & 17 deletions benchmark/single-source/LazyFilter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,37 @@
import TestsUtils

public let LazyFilter = [
BenchmarkInfo(name: "LazilyFilteredArrays2", runFunction: run_LazilyFilteredArrays, tags: [.validation, .api, .Array],
setUpFunction: { blackHole(filteredRange) }),
BenchmarkInfo(name: "LazilyFilteredRange", runFunction: run_LazilyFilteredRange, tags: [.validation, .api, .Array]),
BenchmarkInfo(name: "LazilyFilteredArrays2",
runFunction: run_LazilyFilteredArrays,
tags: [.validation, .api, .Array],
setUpFunction: { blackHole(filteredRange) },
legacyFactor: 100),
BenchmarkInfo(name: "LazilyFilteredRange",
runFunction: run_LazilyFilteredRange,
tags: [.validation, .api, .Array],
legacyFactor: 10),
BenchmarkInfo(
name: "LazilyFilteredArrayContains",
runFunction: run_LazilyFilteredArrayContains,
tags: [.validation, .api, .Array],
setUpFunction: setup_LazilyFilteredArrayContains,
tearDownFunction: teardown_LazilyFilteredArrayContains),
setUpFunction: {
multiplesOfThree = Array(1..<500).lazy.filter { $0 % 3 == 0 } },
tearDownFunction: { multiplesOfThree = nil },
legacyFactor: 100),
]

@inline(never)
public func run_LazilyFilteredRange(_ N: Int) {
var res = 123
let c = (1..<1_000_000).lazy.filter { $0 % 7 == 0 }
let c = (1..<100_000).lazy.filter { $0 % 7 == 0 }
for _ in 1...N {
res += Array(c).count
res -= Array(c).count
}
CheckResults(res == 123)
}

let filteredRange = (1..<100_000).map({[$0]}).lazy.filter { $0.first! % 7 == 0 }
let filteredRange = (1..<1_000).map({[$0]}).lazy.filter { $0.first! % 7 == 0 }

@inline(never)
public func run_LazilyFilteredArrays(_ N: Int) {
Expand All @@ -52,22 +60,14 @@ public func run_LazilyFilteredArrays(_ N: Int) {

fileprivate var multiplesOfThree: LazyFilterCollection<Array<Int>>?

fileprivate func setup_LazilyFilteredArrayContains() {
multiplesOfThree = Array(1..<5_000).lazy.filter { $0 % 3 == 0 }
}

fileprivate func teardown_LazilyFilteredArrayContains() {
multiplesOfThree = nil
}

@inline(never)
fileprivate func run_LazilyFilteredArrayContains(_ N: Int) {
let xs = multiplesOfThree!
for _ in 1...N {
var filteredCount = 0
for candidate in 1..<5_000 {
for candidate in 1..<500 {
filteredCount += xs.contains(candidate) ? 1 : 0
}
CheckResults(filteredCount == 1666)
CheckResults(filteredCount == 166)
}
}
17 changes: 8 additions & 9 deletions benchmark/single-source/LinkedList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ import TestsUtils
public var LinkedList = BenchmarkInfo(
name: "LinkedList",
runFunction: run_LinkedList,
tags: [.runtime, .cpubench, .refcount]
)
tags: [.runtime, .cpubench, .refcount],
setUpFunction: { for i in 0..<size { head = Node(n:head, d:i) } },
tearDownFunction: { head = Node(n:nil, d:0) },
legacyFactor: 40)

let size = 100
var head = Node(n:nil, d:0)

final class Node {
var next: Node?
Expand All @@ -34,16 +39,10 @@ final class Node {

@inline(never)
public func run_LinkedList(_ N: Int) {
let size = 100
var head = Node(n:nil, d:0)
for i in 0..<size {
head = Node(n:head, d:i)
}

var sum = 0
let ref_result = size*(size-1)/2
var ptr = head
for _ in 1...5000*N {
for _ in 1...125*N {
ptr = head
sum = 0
while let nxt = ptr.next {
Expand Down
48 changes: 32 additions & 16 deletions benchmark/single-source/MapReduce.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,41 @@
import TestsUtils
import Foundation

let t: [BenchmarkCategory] = [.validation, .algorithm]
let ts: [BenchmarkCategory] = [.validation, .algorithm, .String]

public let MapReduce = [
BenchmarkInfo(name: "MapReduce", runFunction: run_MapReduce, tags: [.validation, .algorithm]),
BenchmarkInfo(name: "MapReduceAnyCollection", runFunction: run_MapReduceAnyCollection, tags: [.validation, .algorithm]),
BenchmarkInfo(name: "MapReduceAnyCollectionShort", runFunction: run_MapReduceAnyCollectionShort, tags: [.validation, .algorithm]),
BenchmarkInfo(name: "MapReduceClass2", runFunction: run_MapReduceClass, tags: [.validation, .algorithm],
BenchmarkInfo(name: "MapReduce", runFunction: run_MapReduce, tags: t),
BenchmarkInfo(name: "MapReduceAnyCollection",
runFunction: run_MapReduceAnyCollection, tags: t),
BenchmarkInfo(name: "MapReduceAnyCollectionShort",
runFunction: run_MapReduceAnyCollectionShort, tags: t, legacyFactor: 10),
BenchmarkInfo(name: "MapReduceClass2",
runFunction: run_MapReduceClass, tags: t,
setUpFunction: { boxedNumbers(1000) }, tearDownFunction: releaseDecimals),
BenchmarkInfo(name: "MapReduceClassShort2", runFunction: run_MapReduceClassShort, tags: [.validation, .algorithm],
BenchmarkInfo(name: "MapReduceClassShort2",
runFunction: run_MapReduceClassShort, tags: t,
setUpFunction: { boxedNumbers(10) }, tearDownFunction: releaseDecimals),
BenchmarkInfo(name: "MapReduceNSDecimalNumber", runFunction: run_MapReduceNSDecimalNumber, tags: [.validation, .algorithm],
BenchmarkInfo(name: "MapReduceNSDecimalNumber",
runFunction: run_MapReduceNSDecimalNumber, tags: t,
setUpFunction: { decimals(1000) }, tearDownFunction: releaseDecimals),
BenchmarkInfo(name: "MapReduceNSDecimalNumberShort", runFunction: run_MapReduceNSDecimalNumberShort, tags: [.validation, .algorithm],
BenchmarkInfo(name: "MapReduceNSDecimalNumberShort",
runFunction: run_MapReduceNSDecimalNumberShort, tags: t,
setUpFunction: { decimals(10) }, tearDownFunction: releaseDecimals),
BenchmarkInfo(name: "MapReduceLazyCollection", runFunction: run_MapReduceLazyCollection, tags: [.validation, .algorithm]),
BenchmarkInfo(name: "MapReduceLazyCollectionShort", runFunction: run_MapReduceLazyCollectionShort, tags: [.validation, .algorithm]),
BenchmarkInfo(name: "MapReduceLazySequence", runFunction: run_MapReduceLazySequence, tags: [.validation, .algorithm]),
BenchmarkInfo(name: "MapReduceSequence", runFunction: run_MapReduceSequence, tags: [.validation, .algorithm]),
BenchmarkInfo(name: "MapReduceShort", runFunction: run_MapReduceShort, tags: [.validation, .algorithm]),
BenchmarkInfo(name: "MapReduceShortString", runFunction: run_MapReduceShortString, tags: [.validation, .algorithm, .String]),
BenchmarkInfo(name: "MapReduceString", runFunction: run_MapReduceString, tags: [.validation, .algorithm, .String]),
BenchmarkInfo(name: "MapReduceLazyCollection",
runFunction: run_MapReduceLazyCollection, tags: t),
BenchmarkInfo(name: "MapReduceLazyCollectionShort",
runFunction: run_MapReduceLazyCollectionShort, tags: t),
BenchmarkInfo(name: "MapReduceLazySequence",
runFunction: run_MapReduceLazySequence, tags: t),
BenchmarkInfo(name: "MapReduceSequence",
runFunction: run_MapReduceSequence, tags: t),
BenchmarkInfo(name: "MapReduceShort",
runFunction: run_MapReduceShort, tags: t, legacyFactor: 10),
BenchmarkInfo(name: "MapReduceShortString",
runFunction: run_MapReduceShortString, tags: ts),
BenchmarkInfo(name: "MapReduceString",
runFunction: run_MapReduceString, tags: ts),
]

#if _runtime(_ObjC)
Expand Down Expand Up @@ -83,7 +99,7 @@ public func run_MapReduceAnyCollectionShort(_ N: Int) {
let numbers = AnyCollection([Int](0..<10))

var c = 0
for _ in 1...N*10000 {
for _ in 1...N*1_000 {
let mapped = numbers.map { $0 &+ 5 }
c += mapped.reduce(0, &+)
}
Expand All @@ -95,7 +111,7 @@ public func run_MapReduceShort(_ N: Int) {
var numbers = [Int](0..<10)

var c = 0
for _ in 1...N*10000 {
for _ in 1...N*1_000 {
numbers = numbers.map { $0 &+ 5 }
c += numbers.reduce(0, &+)
}
Expand Down
7 changes: 4 additions & 3 deletions benchmark/single-source/MonteCarloE.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import TestsUtils
public let MonteCarloE = BenchmarkInfo(
name: "MonteCarloE",
runFunction: run_MonteCarloE,
tags: [.validation, .algorithm])
tags: [.validation, .algorithm],
legacyFactor: 20)

public func run_MonteCarloE(scale: Int) {
let N = 200000*scale
let N = 10_000*scale
var intervals = [Bool](repeating: false, count: N)
for _ in 1...N {
let pos = Int(UInt(truncatingIfNeeded: Random())%UInt(N))
Expand All @@ -37,5 +38,5 @@ public func run_MonteCarloE(scale: Int) {
CheckResults(numEmptyIntervals != N)
let e_estimate = Double(N)/Double(numEmptyIntervals)
let e = 2.71828
CheckResults(abs(e_estimate - e) < 0.1)
CheckResults(abs(e_estimate - e) < 0.2)
}
7 changes: 4 additions & 3 deletions benchmark/single-source/MonteCarloPi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ import TestsUtils
public let MonteCarloPi = BenchmarkInfo(
name: "MonteCarloPi",
runFunction: run_MonteCarloPi,
tags: [.validation, .algorithm])
tags: [.validation, .algorithm],
legacyFactor: 125)

public func run_MonteCarloPi(scale: Int) {
var pointsInside = 0
let r = 10000
let N = 500000*scale
let N = 4_000*scale
for _ in 1...N {
let x = Int(truncatingIfNeeded: Random())%r
let y = Int(truncatingIfNeeded: Random())%r
Expand All @@ -30,5 +31,5 @@ public func run_MonteCarloPi(scale: Int) {
}
let pi_estimate: Double = Double(pointsInside)*4.0/Double(N)
let pi = 3.1415
CheckResults(abs(pi_estimate - pi) < 0.1)
CheckResults(abs(pi_estimate - pi) < 0.2)
}
5 changes: 3 additions & 2 deletions benchmark/single-source/NSDictionaryCastToSwift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ import TestsUtils
public let NSDictionaryCastToSwift = BenchmarkInfo(
name: "NSDictionaryCastToSwift",
runFunction: run_NSDictionaryCastToSwift,
tags: [.validation, .api, .Dictionary, .bridging])
tags: [.validation, .api, .Dictionary, .bridging],
legacyFactor: 10)

@inline(never)
public func run_NSDictionaryCastToSwift(_ N: Int) {
#if _runtime(_ObjC)
let NSDict = NSDictionary()
var swiftDict = [String: NSObject]()
for _ in 1...10000*N {
for _ in 1...1_000*N {
swiftDict = NSDict as! [String: NSObject]
if !swiftDict.isEmpty {
break
Expand Down
5 changes: 3 additions & 2 deletions benchmark/single-source/NibbleSort.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import TestsUtils
public var NibbleSort = BenchmarkInfo(
name: "NibbleSort",
runFunction: run_NibbleSort,
tags: [.validation]
tags: [.validation],
legacyFactor: 10
)

@inline(never)
Expand All @@ -16,7 +17,7 @@ public func run_NibbleSort(_ N: Int) {
let v: UInt64 = 0xbadbeef
var c = NibbleCollection(v)

for _ in 1...10000*N {
for _ in 1...1_000*N {
c.val = v
c.sort()

Expand Down
5 changes: 3 additions & 2 deletions benchmark/single-source/NopDeinit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import TestsUtils
public let NopDeinit = BenchmarkInfo(
name: "NopDeinit",
runFunction: run_NopDeinit,
tags: [.regression])
tags: [.regression],
legacyFactor: 100)

class X<T : Comparable> {
let deinitIters = 10000
Expand All @@ -32,7 +33,7 @@ class X<T : Comparable> {
public func run_NopDeinit(_ N: Int) {
for _ in 1...N {
var arr :[X<Int>] = []
let size = 500
let size = 5
for i in 1...size { arr.append(X(i)) }
arr.removeAll()
CheckResults(arr.count == 0)
Expand Down
5 changes: 3 additions & 2 deletions benchmark/single-source/ObserverClosure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import TestsUtils
public let ObserverClosure = BenchmarkInfo(
name: "ObserverClosure",
runFunction: run_ObserverClosure,
tags: [.validation])
tags: [.validation],
legacyFactor: 10)

class Observer {
@inline(never)
Expand All @@ -41,7 +42,7 @@ class Signal {
public func run_ObserverClosure(_ iterations: Int) {
let signal = Signal()
let observer = Observer()
for _ in 0 ..< 10_000 * iterations {
for _ in 0 ..< 1_000 * iterations {
signal.subscribe { i in observer.receive(i) }
}
signal.send(1)
Expand Down
5 changes: 3 additions & 2 deletions benchmark/single-source/ObserverForwarderStruct.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import TestsUtils
public let ObserverForwarderStruct = BenchmarkInfo(
name: "ObserverForwarderStruct",
runFunction: run_ObserverForwarderStruct,
tags: [.validation])
tags: [.validation],
legacyFactor: 5)

class Observer {
@inline(never)
Expand Down Expand Up @@ -52,7 +53,7 @@ class Signal {
public func run_ObserverForwarderStruct(_ iterations: Int) {
let signal = Signal()
let observer = Observer()
for _ in 0 ..< 10_000 * iterations {
for _ in 0 ..< 2_000 * iterations {
signal.subscribe(Forwarder(object: observer))
}
signal.send(1)
Expand Down
Loading