I've recently been using the excellent swift-benchmark package: GitHub - google/swift-benchmark: A swift library to benchmark code snippets. (which I hope Apple/Swift.org will adopt one day - it needs to be fleshed-out a bit, but it's really much better than XCTest, especially when it comes to linux support).
One thing that I've found a bit awkward is that it doesn't come with a "black hole" function to prevent the compiler optimising values away. This kind of function appears to be used extensively by the standard library and compiler's own test suite, but implementing your own seems to be non-trivial and relies on insider knowledge about what the compiler can/can't do at this particular point in time.
Is this something the standard library could/should provide?
GitHub issue, and CC @dabrahams who knows more about it than I do. I just need it, and I think that benchmarking should not be considered a niche use-case. Having developers try to trick the compiler doesn't feel like a stable solution.