Skip to content

Commit d8fd19c

Browse files
committed
Merge remote-tracking branch 'origin/main' into test-pr
# Conflicts: # .github/workflows/ci.yml # .github/workflows/documentation.yml # .github/workflows/format.yml
2 parents 06dcc17 + 76c4411 commit d8fd19c

File tree

438 files changed

+4144
-8133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

438 files changed

+4144
-8133
lines changed

.github/package.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 31 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/format.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Format
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency:
9+
group: format-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
swift_format:
14+
name: swift-format
15+
runs-on: macos-15
16+
permissions:
17+
contents: write
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Select Xcode 16.2
21+
run: sudo xcode-select -s /Applications/Xcode_16.2.app
22+
- name: Format
23+
run: make format
24+
- uses: stefanzweifel/git-auto-commit-action@v5
25+
with:
26+
commit_message: Run swift-format
27+
branch: 'main'

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
.DS_Store
2-
/.build
3-
/.swiftpm
2+
.build
3+
.swiftpm
44
/Packages
55
/*.swiftinterface
66
/*.xcodeproj
77
xcuserdata/
8+
.docc-build/
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import Benchmark
2+
import ComposableArchitecture
3+
import Foundation
4+
5+
private func initialState(for nesting: Int) -> Feature.State {
6+
(1..<nesting).reduce(into: Feature.State()) { state, _ in state = Feature.State(child: state) }
7+
}
8+
9+
@MainActor
10+
private func rootStore(for nesting: Int) -> StoreOf<Feature> {
11+
Store(initialState: initialState(for: nesting)) { Feature() }
12+
}
13+
14+
@MainActor
15+
private func scopedStore(for nesting: Int, from root: StoreOf<Feature>? = nil) -> StoreOf<Feature> {
16+
(1..<nesting).reduce(into: root ?? rootStore(for: nesting)) { store, _ in
17+
store = store.scope(state: \.child, action: \.child.presented)!
18+
}
19+
}
20+
21+
let benchmarks = { @Sendable in
22+
Benchmark("Store.Scope") { @MainActor benchmark async in
23+
benchmark.startMeasurement()
24+
_ = scopedStore(for: 1)
25+
}
26+
27+
Benchmark("Store.Send") { @MainActor benchmark async in
28+
let store = scopedStore(for: 1)
29+
benchmark.startMeasurement()
30+
blackHole(store.send(.incrementButtonTapped))
31+
}
32+
33+
Benchmark("Store.Access") { @MainActor benchmark async in
34+
let store = scopedStore(for: 1)
35+
benchmark.startMeasurement()
36+
blackHole(store.state)
37+
}
38+
39+
Benchmark("NestedStore.Scope") { @MainActor benchmark async in
40+
benchmark.startMeasurement()
41+
_ = scopedStore(for: 10)
42+
}
43+
44+
Benchmark("NestedStore.Send") { @MainActor benchmark async in
45+
let store = scopedStore(for: 10)
46+
benchmark.startMeasurement()
47+
blackHole(store.send(.incrementButtonTapped))
48+
}
49+
50+
Benchmark("NestedStore.RootSend") { @MainActor benchmark async in
51+
let root = rootStore(for: 10)
52+
let store = scopedStore(for: 10, from: root)
53+
benchmark.startMeasurement()
54+
blackHole(root.send(.incrementButtonTapped))
55+
}
56+
57+
Benchmark("NestedStore.NestedSend(1)") { @MainActor benchmark async in
58+
let root = rootStore(for: 10)
59+
let store = scopedStore(for: 10, from: root)
60+
benchmark.startMeasurement()
61+
blackHole(root.send(.child(.presented(.incrementButtonTapped))))
62+
}
63+
64+
Benchmark("NestedStore.Access") { @MainActor benchmark async in
65+
let store = scopedStore(for: 10)
66+
benchmark.startMeasurement()
67+
blackHole(store.state)
68+
}
69+
}
70+
71+
@Reducer
72+
private struct Feature {
73+
@ObservableState
74+
struct State {
75+
var count = 0
76+
@Presents var child: Feature.State?
77+
}
78+
enum Action {
79+
indirect case child(PresentationAction<Feature.Action>)
80+
case incrementButtonTapped
81+
}
82+
var body: some ReducerOf<Self> {
83+
Reduce { state, action in
84+
switch action {
85+
case .child:
86+
return .none
87+
case .incrementButtonTapped:
88+
state.count += 1
89+
return .none
90+
}
91+
}
92+
.ifLet(\.$child, action: \.child) {
93+
Feature()
94+
}
95+
}
96+
}

0 commit comments

Comments
 (0)