Skip to content

Commit c59829f

Browse files
committed
data identical benchmarks
1 parent 13970de commit c59829f

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

Benchmarks/Benchmarks/Essentials/BenchmarkEssentials.swift

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ let benchmarks = {
6767
return box
6868
})
6969

70+
Benchmark("DataIdenticalEmpty", closure: { benchmark, box in
71+
blackHole(box.d1.isIdentical(to: box.d2))
72+
}, setup: { () -> TwoDatasBox in
73+
let d1 = Data()
74+
let d2 = d1
75+
let box = TwoDatasBox(d1: d1, d2: d2)
76+
return box
77+
})
78+
7079
Benchmark("DataEqualInline", closure: { benchmark, box in
7180
blackHole(box.d1 == box.d2)
7281
}, setup: { () -> TwoDatasBox in
@@ -75,6 +84,15 @@ let benchmarks = {
7584
let box = TwoDatasBox(d1: d1, d2: d2)
7685
return box
7786
})
87+
88+
Benchmark("DataIdenticalInline", closure: { benchmark, box in
89+
blackHole(box.d1.isIdentical(to: box.d2))
90+
}, setup: { () -> TwoDatasBox in
91+
let d1 = createSomeData(12) // Less than size of InlineData.Buffer
92+
let d2 = d1
93+
let box = TwoDatasBox(d1: d1, d2: d2)
94+
return box
95+
})
7896

7997
Benchmark("DataNotEqualInline", closure: { benchmark, box in
8098
blackHole(box.d1 != box.d2)
@@ -93,7 +111,16 @@ let benchmarks = {
93111
let box = TwoDatasBox(d1: d1, d2: d2)
94112
return box
95113
})
96-
114+
115+
Benchmark("DataIdenticalLarge", closure: { benchmark, box in
116+
blackHole(box.d1.isIdentical(to: box.d2))
117+
}, setup: { () -> TwoDatasBox in
118+
let d1 = createSomeData(1024 * 8)
119+
let d2 = d1
120+
let box = TwoDatasBox(d1: d1, d2: d2)
121+
return box
122+
})
123+
97124
Benchmark("DataNotEqualLarge", closure: { benchmark, box in
98125
blackHole(box.d1 != box.d2)
99126
}, setup: { () -> TwoDatasBox in
@@ -112,6 +139,15 @@ let benchmarks = {
112139
return box
113140
})
114141

142+
Benchmark("DataIdenticalReallyLarge", closure: { benchmark, box in
143+
blackHole(box.d1.isIdentical(to: box.d2))
144+
}, setup: { () -> TwoDatasBox in
145+
let d1 = createSomeData(1024 * 1024 * 8)
146+
let d2 = d1
147+
let box = TwoDatasBox(d1: d1, d2: d2)
148+
return box
149+
})
150+
115151
Benchmark("DataNotEqualReallyLarge", closure: { benchmark, box in
116152
blackHole(box.d1 != box.d2)
117153
}, setup: { () -> TwoDatasBox in

0 commit comments

Comments
 (0)