Skip to content

Commit 414e88d

Browse files
authored
View store benchmark (#1518)
* Add a benchmark for view stores. * wip * wip
1 parent ed34c76 commit 414e88d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Benchmark
2+
import Combine
3+
import ComposableArchitecture
4+
import Foundation
5+
6+
let viewStoreSuite = BenchmarkSuite(name: "ViewStore") {
7+
let store = Store(
8+
initialState: 0,
9+
reducer: EmptyReducer<Int, Void>()
10+
)
11+
12+
$0.benchmark("Create view store to send action") {
13+
doNotOptimizeAway(ViewStore(store).send(()))
14+
}
15+
16+
let viewStore = ViewStore(store)
17+
18+
$0.benchmark("Send action to pre-created view store") {
19+
doNotOptimizeAway(viewStore.send(()))
20+
}
21+
}

Sources/swift-composable-architecture-benchmark/main.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ Benchmark.main([
66
dependenciesSuite,
77
effectSuite,
88
storeScopeSuite,
9+
viewStoreSuite,
910
])

0 commit comments

Comments
 (0)