You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The library should provide a way to ensure that code under test isn't optimized away. The only reliable way I know of to do this that doesn't cost more than a function call is:
(storing values into Any can be costly if they need to be boxed, and anyway if the compiler can prove the Any is never read, it may one day optimize it out).
The text was updated successfully, but these errors were encountered:
Maybe this is better, though it uses a compiler internal:
/// Prevents the value of `x` from being discarded by the optimizer.
///
/// See https://github.com/google/swift-benchmark/issues/69
@inline(__always)fileprivatefunc doNotOptimizeAway<T>(_ x:T){@_optimize(none)func assumePointeeIsRead(_ x:UnsafeRawPointer){}withUnsafePointer(to: x){assumePointeeIsRead($0)}}
The library should provide a way to ensure that code under test isn't optimized away. The only reliable way I know of to do this that doesn't cost more than a function call is:
(storing values into
Any
can be costly if they need to be boxed, and anyway if the compiler can prove theAny
is never read, it may one day optimize it out).The text was updated successfully, but these errors were encountered: