@@ -25,11 +25,13 @@ let setAB = Set(0 ..< size) // 0 ..< 400
25
25
let setCD = Set ( size ..< 2 * size) // 400 ..< 800
26
26
let setBC = Set ( size - quarter ..< 2 * size - quarter) // 300 ..< 700
27
27
let setB = Set ( size - quarter ..< size) // 300 ..< 400
28
+ let setCDS = Set ( size ..< ( size + ( size/ 4 ) ) ) // 400 ..< 500
28
29
29
30
let setOAB = Set ( setAB. map ( Box . init) )
30
31
let setOCD = Set ( setCD. map ( Box . init) )
31
32
let setOBC = Set ( setBC. map ( Box . init) )
32
33
let setOB = Set ( setB. map ( Box . init) )
34
+ let setOCDS = Set ( setCDS. map ( Box . init) )
33
35
34
36
let countA = size - quarter // 300
35
37
let countB = quarter // 100
@@ -368,6 +370,16 @@ public let SetTests = [
368
370
runFunction: { n in run_SetIsDisjointBox ( setOAB, setOCD, true , 50 * n) } ,
369
371
tags: [ . validation, . api, . Set] ,
370
372
setUpFunction: { blackHole ( [ setOAB, setOCD] ) } ) ,
373
+ BenchmarkInfo (
374
+ name: " Set.isDisjoint.Smaller.Int0 " ,
375
+ runFunction: { n in run_SetIsDisjointIntCommutative ( setAB, setCDS, true , 50 * n) } ,
376
+ tags: [ . validation, . api, . Set] ,
377
+ setUpFunction: { blackHole ( [ setAB, setCDS] ) } ) ,
378
+ BenchmarkInfo (
379
+ name: " Set.isDisjoint.Smaller.Box0 " ,
380
+ runFunction: { n in run_SetIsDisjointBoxCommutative ( setOAB, setOCDS, true , 50 * n) } ,
381
+ tags: [ . validation, . api, . Set] ,
382
+ setUpFunction: { blackHole ( [ setOAB, setOCDS] ) } ) ,
371
383
BenchmarkInfo (
372
384
name: " Set.isDisjoint.Int25 " ,
373
385
runFunction: { n in run_SetIsDisjointInt ( setB, setAB, false , 5000 * n) } ,
@@ -891,6 +903,22 @@ public func run_SetIsDisjointInt(
891
903
}
892
904
}
893
905
906
+ // Run isDisjoint Int switching the order of the two sets.
907
+ @inline ( never)
908
+ public func run_SetIsDisjointIntCommutative(
909
+ _ a: Set < Int > ,
910
+ _ b: Set < Int > ,
911
+ _ r: Bool ,
912
+ _ n: Int ) {
913
+ for _ in 0 ..< n {
914
+ let isDisjointA = a. isDisjoint ( with: identity ( b) )
915
+ CheckResults ( isDisjointA == r)
916
+
917
+ let isDisjointB = b. isDisjoint ( with: identity ( a) )
918
+ CheckResults ( isDisjointB == r)
919
+ }
920
+ }
921
+
894
922
@inline ( never)
895
923
public func run_SetIsDisjointSeqInt(
896
924
_ a: Set < Int > ,
@@ -1091,6 +1119,22 @@ func run_SetIsDisjointBox(
1091
1119
}
1092
1120
}
1093
1121
1122
+ // Run isDisjoint Box switching the order of the two sets.
1123
+ @inline ( never)
1124
+ func run_SetIsDisjointBoxCommutative(
1125
+ _ a: Set < Box < Int > > ,
1126
+ _ b: Set < Box < Int > > ,
1127
+ _ r: Bool ,
1128
+ _ n: Int ) {
1129
+ for _ in 0 ..< n {
1130
+ let isDisjointA = a. isDisjoint ( with: identity ( b) )
1131
+ CheckResults ( isDisjointA == r)
1132
+
1133
+ let isDisjointB = b. isDisjoint ( with: identity ( a) )
1134
+ CheckResults ( isDisjointB == r)
1135
+ }
1136
+ }
1137
+
1094
1138
@inline ( never)
1095
1139
func run_SetIsDisjointSeqBox(
1096
1140
_ a: Set < Box < Int > > ,
0 commit comments