I realise this touches on a few other longstanding issues: slow type checking / macro expansion and may not be directly related to Swift Testing.
When using the flags -warn-long-function-bodies= / -warn-long-expression-type-checking= we regularly see hotspots using multiple #expect() statements in a single test:
Are these front end flags reliable with macros and is there anything we can do to help with the type checking — without losing the great diagnostics from using the API as intended.
FWIW the Swift 6.1 toolchain has similar output but in my limited testing, it appears to only impact clean builds. Incremental builds don't show the warning making me think that macro expansion is now being reused across builds in Swift 6.1?
Please file a GitHub issue against the Swift compiler (Sign in to GitHub · GitHub) about this. There is some unavoidable overhead incurred during macro expansion, but it may be possible to improve the type checker's performance overall here.
How did you decide upon the 1ms limit?
I'm using 100ms and occasionally see intermittent warnings with swift-testing. Most of the time it's with parametrized methods and optionals.
Don't worry, we normally use warn-long-function-bodies=600—the use of 1ms highlights the simplest example. We find that any @Test with many #expect() (~10+) can hit the limit on our hardware.
Compiler-level improvements will help in the long term. In the meantime, I'm checking for advice on possible workarounds today. The only solution I can think of is custom matchers, which are much faster and preserve diagnostics, but I'm still not convinced it's worth it.