Skip to content

Document performance: no hot path, no benchmark package - #9

Closed
mackoj wants to merge 1 commit into
chore/architecture-rulesfrom
docs/performance
Closed

mackoj wants to merge 1 commit into
chore/architecture-rulesfrom
docs/performance

Conversation

@mackoj

@mackoj mackoj commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Stacked on #8 (base chore/architecture-rules); merge #8 first and GitHub retargets this to main.

Why no Benchmarks/ package

package-benchmark runs a host executable (macOS/Linux). Every file in this library is wrapped in #if targetEnvironment(simulator), so on the host the module is empty and there is nothing for a benchmark to call; package-benchmark cannot run inside the iOS simulator. Rather than invent a benchmark, docs/performance.md records what the library actually costs where it runs.

Measured on an iPhone 17 simulator (iOS 27, Debug, p50)

What p50
Build an EnvironmentValueItemList of 8 items 4.7 µs
Build the 8 captions 10.3 µs
Apply .environmentVariations (value construction) 4.6 µs
Host + lay out 8 variations in a UIHostingController 113 µs
Baseline: 8 plain padded Texts, no library 97 µs

The library adds ~16 µs to a ~100 µs SwiftUI render inside a preview canvas that spends milliseconds around it. No library change was made: none would be measurable by a user, so there is no before → after table and no release.

The doc also notes one deliberate non-change: HashableEnvironmentValueItem makes a fresh UUID per list build, so variations get new identities when a parent re-renders. Stabilising it changes the public id/Hashable semantics, so it is a behaviour change, not a perf patch.

The library compiles to nothing on the host, where package-benchmark runs.
Measured on an iPhone simulator instead: the library adds about 16 us to
a 100 us render of eight variations, so there is no hot path to improve.
@mackoj

mackoj commented Nov 14, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #12

@mackoj mackoj closed this Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant