Skip to content

Commit 09da304

Browse files
Gumichocopengin8lorentey
authored andcommitted
add benchmark of set isStrictSubset (#23690)
* add benchmark of set isStrictSubset * fix SetIsStrictSubsetBox * bug fixes * change benchmark names to follow naming convention * fix benchmark names
1 parent 844d4df commit 09da304

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

benchmark/single-source/SetTests.swift

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,47 @@ public let SetTests = [
9898
tags: [.validation, .api, .Set],
9999
setUpFunction: { blackHole([setP, setQ]) }),
100100

101+
BenchmarkInfo(
102+
name: "Set.isStrictSubset.Empty.Int",
103+
runFunction: { n in run_SetIsStrictSubsetInt(setE, setAB, true, 5000 * n) },
104+
tags: [.validation, .api, .Set],
105+
setUpFunction: { blackHole([setE, setAB]) }),
106+
BenchmarkInfo(
107+
name: "Set.isStrictSubset.Int.Empty",
108+
runFunction: { n in run_SetIsStrictSubsetInt(setAB, setE, false, 5000 * n) },
109+
tags: [.validation, .api, .Set],
110+
setUpFunction: { blackHole([setAB, setE]) }),
111+
BenchmarkInfo(
112+
name: "Set.isStrictSubset.Int0",
113+
runFunction: { n in run_SetIsStrictSubsetInt(setAB, setCD, false, 5000 * n) },
114+
tags: [.validation, .api, .Set],
115+
setUpFunction: { blackHole([setAB, setCD]) }),
116+
BenchmarkInfo(
117+
name: "Set.isStrictSubset.Box0",
118+
runFunction: { n in run_SetIsStrictSubsetBox(setOAB, setOCD, false, 5000 * n) },
119+
tags: [.validation, .api, .Set],
120+
setUpFunction: { blackHole([setOAB, setOCD]) }),
121+
BenchmarkInfo(
122+
name: "Set.isStrictSubset.Int25",
123+
runFunction: { n in run_SetIsStrictSubsetInt(setB, setAB, true, 50 * n) },
124+
tags: [.validation, .api, .Set],
125+
setUpFunction: { blackHole([setB, setAB]) }),
126+
BenchmarkInfo(
127+
name: "Set.isStrictSubset.Box25",
128+
runFunction: { n in run_SetIsStrictSubsetBox(setOB, setOAB, true, 50 * n) },
129+
tags: [.validation, .api, .Set],
130+
setUpFunction: { blackHole([setOB, setOAB]) }),
131+
BenchmarkInfo(
132+
name: "Set.isStrictSubset.Int50",
133+
runFunction: { n in run_SetIsStrictSubsetInt(setY, setXY, true, 50 * n) },
134+
tags: [.validation, .api, .Set],
135+
setUpFunction: { blackHole([setY, setXY]) }),
136+
BenchmarkInfo(
137+
name: "Set.isStrictSubset.Int100",
138+
runFunction: { n in run_SetIsStrictSubsetInt(setP, setQ, false, 50 * n) },
139+
tags: [.validation, .api, .Set],
140+
setUpFunction: { blackHole([setP, setQ]) }),
141+
101142
BenchmarkInfo(
102143
name: "Set.isDisjoint.Empty.Int",
103144
runFunction: { n in run_SetIsDisjointInt(setE, setAB, true, 5000 * n) },
@@ -333,6 +374,18 @@ public func run_SetIsSubsetInt(
333374
}
334375
}
335376

377+
@inline(never)
378+
public func run_SetIsStrictSubsetInt(
379+
_ a: Set<Int>,
380+
_ b: Set<Int>,
381+
_ r: Bool,
382+
_ n: Int) {
383+
for _ in 0 ..< n {
384+
let isStrictSubset = a.isStrictSubset(of: identity(b))
385+
CheckResults(isStrictSubset == r)
386+
}
387+
}
388+
336389
@inline(never)
337390
public func run_SetSymmetricDifferenceInt(
338391
_ a: Set<Int>,
@@ -421,6 +474,18 @@ func run_SetIsSubsetBox(
421474
}
422475
}
423476

477+
@inline(never)
478+
func run_SetIsStrictSubsetBox(
479+
_ a: Set<Box<Int>>,
480+
_ b: Set<Box<Int>>,
481+
_ r: Bool,
482+
_ n: Int) {
483+
for _ in 0 ..< n {
484+
let isStrictSubset = a.isStrictSubset(of: identity(b))
485+
CheckResults(isStrictSubset == r)
486+
}
487+
}
488+
424489
@inline(never)
425490
func run_SetSymmetricDifferenceBox(
426491
_ a: Set<Box<Int>>,

0 commit comments

Comments
 (0)