Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
37 changes: 0 additions & 37 deletions .github/workflows/build-and-test.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Test

on:
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
build:
name: Test
strategy:
fail-fast: false
matrix:
os: [macos-13]
runs-on: ${{ matrix.os }}
steps:
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.0'

- name: Checkout
uses: actions/checkout@v3

- name: Test
run: |
make test
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ format:
.PHONY: test
test:
swift test -v

.PHONY: benchmark
benchmark:
swift run --configuration release swiftui-simplex-architecture-benchmark
18 changes: 18 additions & 0 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ let package = Package(
.package(url: "https://github.com/pointfreeco/swift-dependencies.git", exact: "1.0.0"),
.package(url: "https://github.com/pointfreeco/swiftui-navigation.git", exact: "1.0.2"),
.package(url: "https://github.com/pointfreeco/swift-macro-testing.git", exact: "0.1.0"),
.package(url: "https://github.com/google/swift-benchmark", from: "0.1.0"),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
Expand All @@ -40,6 +41,13 @@ let package = Package(
.product(name: "SwiftUINavigation", package: "swiftui-navigation"),
]
),
.executableTarget(
name: "swiftui-simplex-architecture-benchmark",
dependencies: [
"SimplexArchitecture",
.product(name: "Benchmark", package: "swift-benchmark"),
]
),
.macro(
name: "SimplexArchitectureMacrosPlugin",
dependencies: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import SimplexArchitecture
import Benchmark
import Combine

let actionSendableSuite = BenchmarkSuite(name: "ActionSendable") {
let testState = TestState()

$0.benchmark("Mutate state") {
testState.count += 1
}

$0.benchmark("Send action") {
testState.send(.increment)
}
}

private struct TestReducer: ReducerProtocol {
enum Action: Equatable {
case increment
}

func reduce(
into state: StateContainer<TestState>,
action: Action
) -> SideEffect<TestReducer> {
switch action {
case .increment:
state.count += 1
return .none
}
}
}

@ViewState
private final class TestState: ObservableObject {
@Published var count = 0
let store: Store<TestReducer> = .init(reducer: TestReducer())

init(count: Int = 0) {
self.count = count
}
}
6 changes: 6 additions & 0 deletions Sources/swiftui-simplex-architecture-benchmark/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Benchmark
import SimplexArchitecture

Benchmark.main([
actionSendableSuite
])