mirror of
https://github.com/pointfreeco/swift-composable-architecture.git
synced 2025-12-20 09:11:33 +01:00
* Fix a bunch of DocC references. * wip * doc fix * issue message fix * swift-navigation 2.0.5
35 lines
811 B
Swift
35 lines
811 B
Swift
import Benchmark
|
|
import ComposableArchitecture
|
|
|
|
@Reducer
|
|
private struct Counter {
|
|
typealias State = Int
|
|
typealias Action = Bool
|
|
var body: some Reducer<State, Action> {
|
|
Reduce { state, action in
|
|
if action {
|
|
state += 1
|
|
return .none
|
|
} else {
|
|
state -= 1
|
|
return .none
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@available(*, deprecated)
|
|
let storeScopeSuite = BenchmarkSuite(name: "Store scoping") { suite in
|
|
var store = Store(initialState: 0) { Counter() }
|
|
var viewStores: [ViewStore<Int, Bool>] = [ViewStore(store, observe: { $0 })]
|
|
for _ in 1...4 {
|
|
store = store.scope(state: { $0 }, action: { $0 })
|
|
viewStores.append(ViewStore(store, observe: { $0 }))
|
|
}
|
|
let lastViewStore = viewStores.last!
|
|
|
|
suite.benchmark("Nested store") {
|
|
lastViewStore.send(true)
|
|
}
|
|
}
|