session-ios/SignalMessaging/utils/Bench.swift
2018-09-27 19:40:51 -04:00

21 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()
}
}