2019-03-10 11:50:24 +03:00
|
|
|
/**
|
|
|
|
* Tae Won Ha - http://taewon.de - @hataewon
|
|
|
|
* See LICENSE
|
|
|
|
*/
|
2019-03-10 11:32:53 +03:00
|
|
|
|
|
|
|
import Cocoa
|
2019-03-10 11:50:24 +03:00
|
|
|
import GameKit
|
|
|
|
import os
|
2019-03-10 11:32:53 +03:00
|
|
|
|
|
|
|
@NSApplicationMain
|
|
|
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
|
|
|
|
|
@IBOutlet weak var window: NSWindow!
|
2019-03-10 11:50:24 +03:00
|
|
|
var result = Array<[[FontGlyphRun]]>(repeating: [], count: count)
|
2019-03-10 11:32:53 +03:00
|
|
|
|
|
|
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
2019-03-10 11:50:24 +03:00
|
|
|
var results = [CFTimeInterval]()
|
|
|
|
let repeatCount = 5
|
|
|
|
for _ in (0..<repeatCount) {
|
|
|
|
let rd = GKRandomDistribution(
|
|
|
|
randomSource: GKMersenneTwisterRandomSource(seed: 129384832),
|
|
|
|
lowestValue: 0,
|
|
|
|
highestValue: repeatCount - 1
|
|
|
|
)
|
|
|
|
let indices = (0..<count).map { i in rd.nextInt() % 3 }
|
|
|
|
|
|
|
|
let time = self.measure {
|
|
|
|
for i in (0..<count) { result[i] = self.perf.render(indices[i]) }
|
|
|
|
}
|
|
|
|
results.append(time)
|
|
|
|
}
|
|
|
|
|
|
|
|
self.log.default(
|
|
|
|
"\(results.reduce(0, +) / Double(results.count))s: \(results)"
|
|
|
|
)
|
|
|
|
|
|
|
|
NSApp.terminate(self)
|
|
|
|
}
|
|
|
|
|
|
|
|
private let perf = PerfTester()
|
|
|
|
|
|
|
|
private let log = OSLog(subsystem: "com.qvacua.DrawerPerf",
|
|
|
|
category: "perf-tester")
|
|
|
|
|
|
|
|
private func measure(_ body: () -> Void) -> CFTimeInterval {
|
|
|
|
let start = CFAbsoluteTimeGetCurrent()
|
|
|
|
body()
|
|
|
|
return CFAbsoluteTimeGetCurrent() - start
|
2019-03-10 11:32:53 +03:00
|
|
|
}
|
|
|
|
}
|
2019-03-10 11:50:24 +03:00
|
|
|
|
|
|
|
private let count = 500
|