[swift-evolution] [Pitch] Retiring `where` from for-in loops

Ben Rimmington me at benrimmington.com
Thu Jun 9 21:05:18 CDT 2016


Erica Sadun wrote:

> public func timetest(_ note: String, block: () -> Void) {
>     let date = NSDate()
>     block()
>     let timeInterval = NSDate().timeIntervalSince(date)
>     print(note); print("Elapsed time: \(timeInterval)")
> }

For performance testing, it might be better to use:

* XCTestCase's `measureBlock {...}`, which uses
* `NSProcessInfo.processInfo().systemUptime`, which uses
* `mach_absolute_time()` or `clock_gettime(CLOCK_MONOTONIC, ...)`

[swift-corelibs-foundation and swift-corelibs-xctest]

-- Ben




More information about the swift-evolution mailing list