|
@@ -154,6 +154,27 @@ class ImageCacheTests: XCTestCase {
|
|
|
waitForExpectationsWithTimeout(1, handler: nil)
|
|
waitForExpectationsWithTimeout(1, handler: nil)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ func testRetrivingImagePerformance() {
|
|
|
|
|
+
|
|
|
|
|
+ let expectation = self.expectationWithDescription("wait for retriving image")
|
|
|
|
|
+
|
|
|
|
|
+ self.cache.storeImage(testImage, forKey: testKeys[0], toDisk: true) { () -> () in
|
|
|
|
|
+
|
|
|
|
|
+ // Base line is ~0.25 in iPhone 6 simulator.
|
|
|
|
|
+ // (Baseline setting for block measure is not available for using in Xcode 6.3 & Swift 1.2)
|
|
|
|
|
+ self.measureBlock({ () -> Void in
|
|
|
|
|
+ for _ in 1 ..< 1000 {
|
|
|
|
|
+ self.cache.retrieveImageInDiskCacheForKey(testKeys[0])
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ expectation.fulfill()
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ self.waitForExpectationsWithTimeout(5, handler: nil)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// MARK: - Helper
|
|
// MARK: - Helper
|
|
|
func storeMultipleImages(completionHandler:()->()) {
|
|
func storeMultipleImages(completionHandler:()->()) {
|
|
|
|
|
|