|
@@ -72,28 +72,29 @@ final class CryptoSwiftTests: XCTestCase {
|
|
|
|
|
|
func testMD5PerformanceSwift() {
|
|
func testMD5PerformanceSwift() {
|
|
self.measureMetrics([XCTPerformanceMetric_WallClockTime], automaticallyStartMeasuring: false, forBlock: { () -> Void in
|
|
self.measureMetrics([XCTPerformanceMetric_WallClockTime], automaticallyStartMeasuring: false, forBlock: { () -> Void in
|
|
- let buf = UnsafeMutablePointer<UInt8>(calloc(2048, sizeof(UInt8)))
|
|
|
|
- let data = NSData(bytes: buf, length: 2048)
|
|
|
|
|
|
+ let buf = UnsafeMutablePointer<UInt8>(calloc(1024 * 1024, sizeof(UInt8)))
|
|
|
|
+ let data = NSData(bytes: buf, length: 1024 * 1024)
|
|
|
|
+ let arr = data.arrayOfBytes()
|
|
self.startMeasuring()
|
|
self.startMeasuring()
|
|
- Hash.md5(data.arrayOfBytes()).calculate()
|
|
|
|
|
|
+ Hash.md5(arr).calculate()
|
|
self.stopMeasuring()
|
|
self.stopMeasuring()
|
|
- buf.dealloc(1024)
|
|
|
|
|
|
+ buf.dealloc(1024 * 1024)
|
|
buf.destroy()
|
|
buf.destroy()
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
func testMD5PerformanceCommonCrypto() {
|
|
func testMD5PerformanceCommonCrypto() {
|
|
self.measureMetrics([XCTPerformanceMetric_WallClockTime], automaticallyStartMeasuring: false, forBlock: { () -> Void in
|
|
self.measureMetrics([XCTPerformanceMetric_WallClockTime], automaticallyStartMeasuring: false, forBlock: { () -> Void in
|
|
- let buf = UnsafeMutablePointer<UInt8>(calloc(2048, sizeof(UInt8)))
|
|
|
|
- let data = NSData(bytes: buf, length: 2048)
|
|
|
|
- self.startMeasuring()
|
|
|
|
|
|
+ let buf = UnsafeMutablePointer<UInt8>(calloc(1024 * 1024, sizeof(UInt8)))
|
|
|
|
+ let data = NSData(bytes: buf, length: 1024 * 1024)
|
|
let outbuf = UnsafeMutablePointer<UInt8>.alloc(Int(CC_MD5_DIGEST_LENGTH))
|
|
let outbuf = UnsafeMutablePointer<UInt8>.alloc(Int(CC_MD5_DIGEST_LENGTH))
|
|
- CC_MD5(data.bytes, CC_LONG(data.length), outbuf)
|
|
|
|
|
|
+ self.startMeasuring()
|
|
|
|
+ CC_MD5(data.bytes, CC_LONG(data.length), outbuf)
|
|
//let output = NSData(bytes: outbuf, length: Int(CC_MD5_DIGEST_LENGTH));
|
|
//let output = NSData(bytes: outbuf, length: Int(CC_MD5_DIGEST_LENGTH));
|
|
|
|
+ self.stopMeasuring()
|
|
outbuf.dealloc(Int(CC_MD5_DIGEST_LENGTH))
|
|
outbuf.dealloc(Int(CC_MD5_DIGEST_LENGTH))
|
|
outbuf.destroy()
|
|
outbuf.destroy()
|
|
- self.stopMeasuring()
|
|
|
|
- buf.dealloc(1024)
|
|
|
|
|
|
+ buf.dealloc(1024 * 1024)
|
|
buf.destroy()
|
|
buf.destroy()
|
|
})
|
|
})
|
|
}
|
|
}
|