Skip to content

Commit 9a3a9a0

Browse files
committed
Add performance test for retrieving image
1 parent e73a1ba commit 9a3a9a0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

KingfisherTests/ImageCacheTests.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,27 @@ class ImageCacheTests: XCTestCase {
154154
waitForExpectationsWithTimeout(1, handler: nil)
155155
}
156156

157+
func testRetrivingImagePerformance() {
158+
159+
let expectation = self.expectationWithDescription("wait for retriving image")
160+
161+
self.cache.storeImage(testImage, forKey: testKeys[0], toDisk: true) { () -> () in
162+
163+
// Base line is ~0.25 in iPhone 6 simulator.
164+
// (Baseline setting for block measure is not available for using in Xcode 6.3 & Swift 1.2)
165+
self.measureBlock({ () -> Void in
166+
for _ in 1 ..< 1000 {
167+
self.cache.retrieveImageInDiskCacheForKey(testKeys[0])
168+
}
169+
})
170+
171+
expectation.fulfill()
172+
173+
}
174+
175+
self.waitForExpectationsWithTimeout(5, handler: nil)
176+
}
177+
157178
// MARK: - Helper
158179
func storeMultipleImages(completionHandler:()->()) {
159180

0 commit comments

Comments
 (0)