session-ios/SignalMessaging/utils/Bench.swift
Michael Kirk 4c2d30a776 Memory warning clears MediaPageView cache
Doing so required MediaDetailView to retain GalleryItem, but because
GalleryItem is a swift struct, I had to envoke the Box dance.

// FREEBIE
2018-03-19 18:57:10 -04:00

22 lines
505 B
Swift

//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
import Foundation
public func BenchAsync(title: String, block: (() -> Void) -> Void) {
let startTime = CFAbsoluteTimeGetCurrent()
block {
let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime
Logger.debug("[Bench] title: \(title), duration: \(timeElapsed)")
}
}
public func Bench(title: String, block: () -> Void) {
BenchAsync(title: title) { finish in
block()
finish()
}
}