Skip to content

Add a blackHole #69

Open
Open
@dabrahams

Description

@dabrahams

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:

notOptimizedAway<T>(_ x: T) { 
  withUnsafePointer(to: x) { opaqueCFunctionTakingVoidConstStar($0) }
}

(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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions