UIImageJPEGRepresentation wrapped in Autorelease Pool Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Test_JPEGRepresentation_AutoRelease(iterations: Int, compressionRatio: CGFloat,image: UIImage) { | |
//Gather the initial information | |
let startReading = report_memory() | |
print("Memory at start: \(startReading / 1024 / 1024) mb") | |
//Loop through the number of test iterations specified | |
for index in 1...iterations { | |
if let data = UIImageToDataJPEG2(image: image, compressionRatio: compressionRatio) { | |
//Sample the length of the first result to make sure we are comparing the same size | |
if index == 1 { | |
//Report out results | |
let dataSize = Int(data.count / 1024 / 1024) | |
print("Data Length: \(dataSize) mb") | |
} | |
} | |
} | |
let endReading = report_memory() | |
print("Memory at finish: \(Int(endReading / 1024 / 1024)) mb") | |
let delta = (Int(Int(endReading) - Int(startReading)) / 1024 / 1024) | |
print("Memory delta: \(delta) mb") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment