Skip to content

Instantly share code, notes, and snippets.

@rxg9527
rxg9527 / UIDevice-XGExtension.swift
Created December 26, 2017 02:14
判断 iPhone 机型
extension UIDevice {
static func isX() -> Bool {
if UIDevice().userInterfaceIdiom == .phone {
switch UIScreen.main.nativeBounds.height {
case 2436:
return true
default:
return false
// case 480:
// print("iPhone Classic")
@rxg9527
rxg9527 / MeasureFunctionTime.swift
Created December 26, 2017 02:13
性能测试:通过输出 log 来监测某一段程序运行所消耗的时间
func measure(f: ()->()) {
let start = CACurrentMediaTime()
f()
let end = CACurrentMediaTime()
print("测量时间:\(end - start)")
}
measure {
doSomeHeavyWork()
}