@@ -16,6 +16,10 @@ let size = 400
16
16
let half = size / 2
17
17
let quarter = size / 4
18
18
19
+ // Construction of empty sets.
20
+ let setE : Set < Int > = [ ]
21
+ let setOE : Set < Box < Int > > = [ ]
22
+
19
23
// Construction kit for sets with 25% overlap
20
24
let setAB = Set ( 0 ..< size) // 0 ..< 400
21
25
let setCD = Set ( size ..< 2 * size) // 400 ..< 800
@@ -53,6 +57,11 @@ let setQ: Set<Int> = {
53
57
54
58
public let SetTests = [
55
59
// Mnemonic: number after name is percentage of common elements in input sets.
60
+ BenchmarkInfo (
61
+ name: " Set.Empty.IsSubsetInt0 " ,
62
+ runFunction: { n in run_SetIsSubsetInt ( setE, setAB, true , 5000 * n) } ,
63
+ tags: [ . validation, . api, . Set] ,
64
+ setUpFunction: { blackHole ( [ setE, setAB] ) } ) ,
56
65
BenchmarkInfo (
57
66
name: " SetIsSubsetInt0 " ,
58
67
runFunction: { n in run_SetIsSubsetInt ( setAB, setCD, false , 5000 * n) } ,
@@ -84,6 +93,47 @@ public let SetTests = [
84
93
tags: [ . validation, . api, . Set] ,
85
94
setUpFunction: { blackHole ( [ setP, setQ] ) } ) ,
86
95
96
+ BenchmarkInfo (
97
+ name: " Set.Empty.IsDisjointInt0 " ,
98
+ runFunction: { n in run_SetIsDisjointInt ( setE, setAB, true , 50 * n) } ,
99
+ tags: [ . validation, . api, . Set] ,
100
+ setUpFunction: { blackHole ( [ setE, setAB] ) } ) ,
101
+ BenchmarkInfo (
102
+ name: " Set.Empty.IsDisjointBox0 " ,
103
+ runFunction: { n in run_SetIsDisjointBox ( setOE, setOAB, true , 50 * n) } ,
104
+ tags: [ . validation, . api, . Set] ,
105
+ setUpFunction: { blackHole ( [ setOE, setOAB] ) } ) ,
106
+ BenchmarkInfo (
107
+ name: " SetIsDisjointInt0 " ,
108
+ runFunction: { n in run_SetIsDisjointInt ( setAB, setCD, true , 50 * n) } ,
109
+ tags: [ . validation, . api, . Set] ,
110
+ setUpFunction: { blackHole ( [ setAB, setCD] ) } ) ,
111
+ BenchmarkInfo (
112
+ name: " SetIsDisjointBox0 " ,
113
+ runFunction: { n in run_SetIsDisjointBox ( setOAB, setOCD, true , 50 * n) } ,
114
+ tags: [ . validation, . api, . Set] ,
115
+ setUpFunction: { blackHole ( [ setOAB, setOCD] ) } ) ,
116
+ BenchmarkInfo (
117
+ name: " SetIsDisjointInt25 " ,
118
+ runFunction: { n in run_SetIsDisjointInt ( setB, setAB, false , 50 * n) } ,
119
+ tags: [ . validation, . api, . Set] ,
120
+ setUpFunction: { blackHole ( [ setB, setAB] ) } ) ,
121
+ BenchmarkInfo (
122
+ name: " SetIsDisjointBox25 " ,
123
+ runFunction: { n in run_SetIsDisjointBox ( setOB, setOAB, false , 50 * n) } ,
124
+ tags: [ . validation, . api, . Set] ,
125
+ setUpFunction: { blackHole ( [ setOB, setOAB] ) } ) ,
126
+ BenchmarkInfo (
127
+ name: " SetIsDisjointInt50 " ,
128
+ runFunction: { n in run_SetIsDisjointInt ( setY, setXY, false , 50 * n) } ,
129
+ tags: [ . validation, . api, . Set] ,
130
+ setUpFunction: { blackHole ( [ setY, setXY] ) } ) ,
131
+ BenchmarkInfo (
132
+ name: " SetIsDisjointInt100 " ,
133
+ runFunction: { n in run_SetIsDisjointInt ( setP, setQ, false , 50 * n) } ,
134
+ tags: [ . validation, . api, . Set] ,
135
+ setUpFunction: { blackHole ( [ setP, setQ] ) } ) ,
136
+
87
137
BenchmarkInfo (
88
138
name: " SetSymmetricDifferenceInt0 " ,
89
139
runFunction: { n in run_SetSymmetricDifferenceInt ( setAB, setCD, countABCD, 10 * n) } ,
@@ -177,6 +227,16 @@ public let SetTests = [
177
227
tags: [ . validation, . api, . Set] ,
178
228
setUpFunction: { blackHole ( [ setP, setQ] ) } ) ,
179
229
230
+ BenchmarkInfo (
231
+ name: " Set.Empty.SubtractingInt0 " ,
232
+ runFunction: { n in run_SetSubtractingInt ( setE, setAB, 0 , 10 * n) } ,
233
+ tags: [ . validation, . api, . Set] ,
234
+ setUpFunction: { blackHole ( [ setE, setAB] ) } ) ,
235
+ BenchmarkInfo (
236
+ name: " Set.Empty.SubtractingBox0 " ,
237
+ runFunction: { n in run_SetSubtractingBox ( setOE, setOAB, 0 , 10 * n) } ,
238
+ tags: [ . validation, . api, . Set] ,
239
+ setUpFunction: { blackHole ( [ setOE, setOAB] ) } ) ,
180
240
BenchmarkInfo (
181
241
name: " SetSubtractingInt0 " ,
182
242
runFunction: { n in run_SetSubtractingInt ( setAB, setCD, countAB, 10 * n) } ,
@@ -296,6 +356,18 @@ public func run_SetSubtractingInt(
296
356
}
297
357
}
298
358
359
+ @inline ( never)
360
+ public func run_SetIsDisjointInt(
361
+ _ a: Set < Int > ,
362
+ _ b: Set < Int > ,
363
+ _ r: Bool ,
364
+ _ n: Int ) {
365
+ for _ in 0 ..< n {
366
+ let isDisjoint = a. isDisjoint ( with: identity ( b) )
367
+ CheckResults ( isDisjoint == r)
368
+ }
369
+ }
370
+
299
371
class Box < T : Hashable > : Hashable {
300
372
var value : T
301
373
@@ -371,3 +443,15 @@ func run_SetSubtractingBox(
371
443
CheckResults ( and. count == r)
372
444
}
373
445
}
446
+
447
+ @inline ( never)
448
+ func run_SetIsDisjointBox(
449
+ _ a: Set < Box < Int > > ,
450
+ _ b: Set < Box < Int > > ,
451
+ _ r: Bool ,
452
+ _ n: Int ) {
453
+ for _ in 0 ..< n {
454
+ let isDisjoint = a. isDisjoint ( with: identity ( b) )
455
+ CheckResults ( isDisjoint == r)
456
+ }
457
+ }
0 commit comments