Преглед на файлове

Separate performance tests

Marcin Krzyżanowski преди 7 години
родител
ревизия
5974f24e40

+ 25 - 1
CryptoSwift.xcodeproj/project.pbxproj

@@ -41,6 +41,12 @@
 		754BE46819693E190098E6F3 /* DigestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 754BE46719693E190098E6F3 /* DigestTests.swift */; };
 		755FB1DA199E347D00475437 /* ExtensionsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 755FB1D9199E347D00475437 /* ExtensionsTest.swift */; };
 		7576F64D20725BD6006688F8 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7576F64C20725BD5006688F8 /* Default-568h@2x.png */; };
+		7576F6ED20726325006688F8 /* DigestTestsPerf.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7576F6EB20726319006688F8 /* DigestTestsPerf.swift */; };
+		7576F6EF20726422006688F8 /* AESTestsPerf.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7576F6EE20726422006688F8 /* AESTestsPerf.swift */; };
+		7576F6F120728EAB006688F8 /* ChaCha20TestsPerf.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7576F6F020728EAB006688F8 /* ChaCha20TestsPerf.swift */; };
+		7576F6F320728F00006688F8 /* RabbitTestsPerf.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7576F6F220728F00006688F8 /* RabbitTestsPerf.swift */; };
+		7576F6F520729069006688F8 /* ExtensionsTestPerf.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7576F6F420729069006688F8 /* ExtensionsTestPerf.swift */; };
+		7576F6F7207290F8006688F8 /* PBKDFPerf.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7576F6F6207290F8006688F8 /* PBKDFPerf.swift */; };
 		757DA2531A4ED0A4002BA3EF /* PaddingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757DA2521A4ED0A4002BA3EF /* PaddingTests.swift */; };
 		757DA2551A4ED408002BA3EF /* AESTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757DA2541A4ED408002BA3EF /* AESTests.swift */; };
 		757DA2591A4ED4D7002BA3EF /* ChaCha20Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 757DA2581A4ED4D7002BA3EF /* ChaCha20Tests.swift */; };
@@ -220,6 +226,12 @@
 		755FB1D9199E347D00475437 /* ExtensionsTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExtensionsTest.swift; sourceTree = "<group>"; };
 		756BFDCA1A82B87300B9D9A4 /* Bridging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bridging.h; sourceTree = "<group>"; };
 		7576F64C20725BD5006688F8 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
+		7576F6EB20726319006688F8 /* DigestTestsPerf.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DigestTestsPerf.swift; sourceTree = "<group>"; };
+		7576F6EE20726422006688F8 /* AESTestsPerf.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AESTestsPerf.swift; sourceTree = "<group>"; };
+		7576F6F020728EAB006688F8 /* ChaCha20TestsPerf.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChaCha20TestsPerf.swift; sourceTree = "<group>"; };
+		7576F6F220728F00006688F8 /* RabbitTestsPerf.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RabbitTestsPerf.swift; sourceTree = "<group>"; };
+		7576F6F420729069006688F8 /* ExtensionsTestPerf.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExtensionsTestPerf.swift; sourceTree = "<group>"; };
+		7576F6F6207290F8006688F8 /* PBKDFPerf.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PBKDFPerf.swift; sourceTree = "<group>"; };
 		757DA2521A4ED0A4002BA3EF /* PaddingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PaddingTests.swift; sourceTree = "<group>"; };
 		757DA2541A4ED408002BA3EF /* AESTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AESTests.swift; sourceTree = "<group>"; };
 		757DA2581A4ED4D7002BA3EF /* ChaCha20Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChaCha20Tests.swift; sourceTree = "<group>"; };
@@ -348,7 +360,6 @@
 		754BE44B19693E190098E6F3 = {
 			isa = PBXGroup;
 			children = (
-				7576F64C20725BD5006688F8 /* Default-568h@2x.png */,
 				75843E9A2072457A0050583A /* config */,
 				755D27BC1D06DE6400C41692 /* CryptoSwift.playground */,
 				75EC52361EE8B6CA0048EB3B /* Sources */,
@@ -375,17 +386,23 @@
 				14156CE42011422400DDCFBC /* ChaCha20Poly1305Tests.swift */,
 				E3FD2D511D6B813C00A9F35F /* Error+Extension.swift */,
 				754BE46719693E190098E6F3 /* DigestTests.swift */,
+				7576F6EB20726319006688F8 /* DigestTestsPerf.swift */,
 				75100F8E19B0BC890005C5F5 /* Poly1305Tests.swift */,
 				758A94271A65C59200E46135 /* HMACTests.swift */,
 				0EE73E72204D599C00110E11 /* CMACTests.swift */,
 				E6200E151FB9B67C00258382 /* HKDFTests.swift */,
 				757DA2541A4ED408002BA3EF /* AESTests.swift */,
+				7576F6EE20726422006688F8 /* AESTestsPerf.swift */,
 				750CC3EA1DC0CACE0096BE6E /* BlowfishTests.swift */,
 				757DA2581A4ED4D7002BA3EF /* ChaCha20Tests.swift */,
+				7576F6F020728EAB006688F8 /* ChaCha20TestsPerf.swift */,
 				674A736E1BF5D85B00866C5B /* RabbitTests.swift */,
+				7576F6F220728F00006688F8 /* RabbitTestsPerf.swift */,
 				755FB1D9199E347D00475437 /* ExtensionsTest.swift */,
+				7576F6F420729069006688F8 /* ExtensionsTestPerf.swift */,
 				757DA2521A4ED0A4002BA3EF /* PaddingTests.swift */,
 				75482EA31CB310B7001F66A5 /* PBKDF.swift */,
+				7576F6F6207290F8006688F8 /* PBKDFPerf.swift */,
 				753B33001DAB84D600D06422 /* RandomBytesSequenceTests.swift */,
 				75C2E76C1D55F097003D2BCA /* Access.swift */,
 				756BFDCA1A82B87300B9D9A4 /* Bridging.h */,
@@ -399,6 +416,7 @@
 			isa = PBXGroup;
 			children = (
 				75EDCB811DAC4CA400D270E0 /* LinuxMain.swift */,
+				7576F64C20725BD5006688F8 /* Default-568h@2x.png */,
 				754BE46619693E190098E6F3 /* Info.plist */,
 			);
 			name = "Supporting Files";
@@ -784,6 +802,7 @@
 			files = (
 				75C2E76D1D55F097003D2BCA /* Access.swift in Sources */,
 				75482EA41CB310B7001F66A5 /* PBKDF.swift in Sources */,
+				7576F6F520729069006688F8 /* ExtensionsTestPerf.swift in Sources */,
 				758A94291A65C67400E46135 /* HMACTests.swift in Sources */,
 				75100F8F19B0BC890005C5F5 /* Poly1305Tests.swift in Sources */,
 				E6200E171FB9B68C00258382 /* HKDFTests.swift in Sources */,
@@ -795,6 +814,11 @@
 				674A736F1BF5D85B00866C5B /* RabbitTests.swift in Sources */,
 				0EE73E74204D59C200110E11 /* CMACTests.swift in Sources */,
 				750CC3EB1DC0CACE0096BE6E /* BlowfishTests.swift in Sources */,
+				7576F6F7207290F8006688F8 /* PBKDFPerf.swift in Sources */,
+				7576F6F120728EAB006688F8 /* ChaCha20TestsPerf.swift in Sources */,
+				7576F6ED20726325006688F8 /* DigestTestsPerf.swift in Sources */,
+				7576F6EF20726422006688F8 /* AESTestsPerf.swift in Sources */,
+				7576F6F320728F00006688F8 /* RabbitTestsPerf.swift in Sources */,
 				757DA2531A4ED0A4002BA3EF /* PaddingTests.swift in Sources */,
 				14156CE52011422400DDCFBC /* ChaCha20Poly1305Tests.swift in Sources */,
 				757DA2551A4ED408002BA3EF /* AESTests.swift in Sources */,

+ 1 - 33
Tests/CryptoSwiftTests/AESTests.swift

@@ -363,34 +363,9 @@ final class AESTests: XCTestCase {
     }
 }
 
-#if !CI
-
-    extension AESTests {
-        func testAESEncryptPerformance() {
-            let key: Array<UInt8> = [0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c]
-            let iv: Array<UInt8> = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f]
-            let message = Array<UInt8>(repeating: 7, count: 1024 * 1024)
-            let aes = try! AES(key: key, blockMode: .CBC(iv: iv), padding: .pkcs7)
-            measure {
-                _ = try! aes.encrypt(message)
-            }
-        }
-
-        func testAESDecryptPerformance() {
-            let key: Array<UInt8> = [0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c]
-            let iv: Array<UInt8> = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f]
-            let message = Array<UInt8>(repeating: 7, count: 1024 * 1024)
-            let aes = try! AES(key: key, blockMode: .CBC(iv: iv), padding: .pkcs7)
-            measure {
-                _ = try! aes.decrypt(message)
-            }
-        }
-    }
-#endif
-
 extension AESTests {
     static func allTests() -> [(String, (AESTests) -> () -> Void)] {
-        var tests = [
+        let tests = [
             ("testAESEncrypt", testAESEncrypt),
             ("testAESEncrypt2", testAESEncrypt2),
             ("testAESEncrypt3", testAESEncrypt3),
@@ -414,13 +389,6 @@ extension AESTests {
             ("testIssue411", testIssue411),
             ("testAESWithWrongKey", testAESWithWrongKey),
         ]
-
-        #if !CI
-            tests += [
-                ("testAESEncryptPerformance", testAESEncryptPerformance),
-                ("testAESDecryptPerformance", testAESDecryptPerformance),
-            ]
-        #endif
         return tests
     }
 }

+ 50 - 0
Tests/CryptoSwiftTests/AESTestsPerf.swift

@@ -0,0 +1,50 @@
+//
+//  CryptoSwift
+//
+//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
+//  This software is provided 'as-is', without any express or implied warranty.
+//
+//  In no event will the authors be held liable for any damages arising from the use of this software.
+//
+//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
+//
+//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
+//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+//  - This notice may not be removed or altered from any source or binary distribution.
+//
+
+@testable import CryptoSwift
+import Foundation
+import XCTest
+
+final class AESTestsPerf: XCTestCase {
+    func testAESEncryptPerformance() {
+        let key: Array<UInt8> = [0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c]
+        let iv: Array<UInt8> = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f]
+        let message = Array<UInt8>(repeating: 7, count: 1024 * 1024)
+        let aes = try! AES(key: key, blockMode: .CBC(iv: iv), padding: .pkcs7)
+        measure {
+            _ = try! aes.encrypt(message)
+        }
+    }
+
+    func testAESDecryptPerformance() {
+        let key: Array<UInt8> = [0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c]
+        let iv: Array<UInt8> = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f]
+        let message = Array<UInt8>(repeating: 7, count: 1024 * 1024)
+        let aes = try! AES(key: key, blockMode: .CBC(iv: iv), padding: .pkcs7)
+        measure {
+            _ = try! aes.decrypt(message)
+        }
+    }
+}
+
+extension AESTestsPerf {
+    static func allTests() -> [(String, (AESTestsPerf) -> () -> Void)] {
+        let tests = [
+            ("testAESEncryptPerformance", testAESEncryptPerformance),
+            ("testAESDecryptPerformance", testAESDecryptPerformance),
+        ]
+        return tests
+    }
+}

+ 1 - 24
Tests/CryptoSwiftTests/ChaCha20Tests.swift

@@ -108,38 +108,15 @@ final class ChaCha20Tests: XCTestCase {
     }
 }
 
-#if !CI
-
-    extension ChaCha20Tests {
-        func testChaCha20Performance() {
-            let key: Array<UInt8> = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f]
-            let iv: Array<UInt8> = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]
-            let message = Array<UInt8>(repeating: 7, count: 1024 * 1024)
-            measureMetrics([XCTPerformanceMetric.wallClockTime], automaticallyStartMeasuring: true, for: { () -> Void in
-                do {
-                    _ = try ChaCha20(key: key, iv: iv).encrypt(message)
-                } catch {
-                    XCTFail()
-                }
-                self.stopMeasuring()
-            })
-        }
-    }
-#endif
-
 extension ChaCha20Tests {
     static func allTests() -> [(String, (ChaCha20Tests) -> () -> Void)] {
-        var tests = [
+        let tests = [
             ("testChaCha20", testChaCha20),
             ("testCore", testCore),
             ("testVector1Py", testVector1Py),
             ("testChaCha20EncryptPartial", testChaCha20EncryptPartial),
         ]
 
-        #if !CI
-            tests += [("testChaCha20Performance", testChaCha20Performance)]
-        #endif
-
         return tests
     }
 }

+ 41 - 0
Tests/CryptoSwiftTests/ChaCha20TestsPerf.swift

@@ -0,0 +1,41 @@
+//
+//  CryptoSwift
+//
+//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
+//  This software is provided 'as-is', without any express or implied warranty.
+//
+//  In no event will the authors be held liable for any damages arising from the use of this software.
+//
+//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
+//
+//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
+//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+//  - This notice may not be removed or altered from any source or binary distribution.
+//
+
+@testable import CryptoSwift
+import Foundation
+import XCTest
+
+final class ChaCha20TestsPerf: XCTestCase {
+    func testChaCha20Performance() {
+        let key: Array<UInt8> = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f]
+        let iv: Array<UInt8> = [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]
+        let message = Array<UInt8>(repeating: 7, count: 1024 * 1024)
+        measureMetrics([XCTPerformanceMetric.wallClockTime], automaticallyStartMeasuring: true) { () -> Void in
+            do {
+                _ = try ChaCha20(key: key, iv: iv).encrypt(message)
+            } catch {
+                XCTFail()
+            }
+            self.stopMeasuring()
+        }
+    }
+}
+
+extension ChaCha20TestsPerf {
+    static func allTests() -> [(String, (ChaCha20TestsPerf) -> () -> Void)] {
+        let tests = [("testChaCha20Performance", testChaCha20Performance)]
+        return tests
+    }
+}

+ 0 - 0
Default-568h@2x.png → Tests/CryptoSwiftTests/Default-568h@2x.png


+ 1 - 45
Tests/CryptoSwiftTests/DigestTests.swift

@@ -256,46 +256,9 @@ final class DigestTests: XCTestCase {
     }
 }
 
-#if !CI
-
-    extension DigestTests {
-        func testMD5Performance() {
-            measureMetrics([XCTPerformanceMetric.wallClockTime], automaticallyStartMeasuring: false) {
-                let arr = Array<UInt8>(repeating: 200, count: 1024 * 1024)
-                self.startMeasuring()
-                _ = Digest.md5(arr)
-                self.stopMeasuring()
-            }
-        }
-
-        func testSHA1Performance() {
-            measureMetrics([XCTPerformanceMetric.wallClockTime], automaticallyStartMeasuring: false) {
-                let arr = Array<UInt8>(repeating: 200, count: 1024 * 1024)
-                self.startMeasuring()
-                _ = Digest.sha1(arr)
-                self.stopMeasuring()
-            }
-        }
-
-        // Keep it to compare
-        /*
-         func testSHA1PerformanceCC() {
-         measureMetrics([XCTPerformanceMetric.wallClockTime], automaticallyStartMeasuring: false) {
-         let arr = Array<UInt8>(repeating: 200, count: 1024 * 1024)
-         self.startMeasuring()
-         var digest = Array<UInt8>(repeating: 0, count: Int(CC_SHA1_DIGEST_LENGTH))
-         CC_SHA1(arr, CC_LONG(arr.count), &digest)
-         self.stopMeasuring()
-         }
-         }
-         */
-    }
-
-#endif
-
 extension DigestTests {
     static func allTests() -> [(String, (DigestTests) -> () -> Void)] {
-        var tests = [
+        let tests = [
             ("testMD5", testMD5),
             ("testSHA1", testSHA1),
             ("testSHA2", testSHA2),
@@ -311,13 +274,6 @@ extension DigestTests {
             ("testSHAPartialUpdates", testSHAPartialUpdates),
         ]
 
-        #if !CI
-            tests += [
-                ("testMD5Performance", testMD5Performance),
-                ("testSHA1Performance", testSHA1Performance),
-            ]
-        #endif
-
         return tests
     }
 }

+ 63 - 0
Tests/CryptoSwiftTests/DigestTestsPerf.swift

@@ -0,0 +1,63 @@
+//
+//  CryptoSwift
+//
+//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
+//  This software is provided 'as-is', without any express or implied warranty.
+//
+//  In no event will the authors be held liable for any damages arising from the use of this software.
+//
+//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
+//
+//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
+//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+//  - This notice may not be removed or altered from any source or binary distribution.
+//
+
+// http://www.di-mgt.com.au/sha_testvectors.html (http://csrc.nist.gov/groups/ST/toolkit/documents/Examples/SHA_All.pdf)
+//
+
+@testable import CryptoSwift
+import Foundation
+import XCTest
+
+final class DigestTestsPerf: XCTestCase {
+    func testMD5Performance() {
+        measureMetrics([XCTPerformanceMetric.wallClockTime], automaticallyStartMeasuring: false) {
+            let arr = Array<UInt8>(repeating: 200, count: 1024 * 1024)
+            self.startMeasuring()
+            _ = Digest.md5(arr)
+            self.stopMeasuring()
+        }
+    }
+
+    func testSHA1Performance() {
+        measureMetrics([XCTPerformanceMetric.wallClockTime], automaticallyStartMeasuring: false) {
+            let arr = Array<UInt8>(repeating: 200, count: 1024 * 1024)
+            self.startMeasuring()
+            _ = Digest.sha1(arr)
+            self.stopMeasuring()
+        }
+    }
+
+    // Keep it to compare
+    /*
+    func testSHA1PerformanceCC() {
+        measureMetrics([XCTPerformanceMetric.wallClockTime], automaticallyStartMeasuring: false) {
+            let arr = Array<UInt8>(repeating: 200, count: 1024 * 1024)
+            self.startMeasuring()
+            var digest = Array<UInt8>(repeating: 0, count: Int(CC_SHA1_DIGEST_LENGTH))
+            CC_SHA1(arr, CC_LONG(arr.count), &digest)
+            self.stopMeasuring()
+        }
+    }
+    */
+}
+
+extension DigestTestsPerf {
+    static func allTests() -> [(String, (DigestTestsPerf) -> () -> Void)] {
+        return [
+            ("testMD5Performance", testMD5Performance),
+            ("testSHA1Performance", testSHA1Performance)
+        ]
+    }
+}

+ 1 - 21
Tests/CryptoSwiftTests/ExtensionsTest.swift

@@ -84,24 +84,9 @@ final class ExtensionsTest: XCTestCase {
     }
 }
 
-#if !CI
-
-    extension ExtensionsTest {
-        func testArrayInitHexPerformance() {
-            var str = "b1b2b3b3b3b3b3b3b1b2b3b3b3b3b3b3"
-            for _ in 0...12 {
-                str += str
-            }
-            measure {
-                _ = Array<UInt8>(hex: str)
-            }
-        }
-    }
-#endif
-
 extension ExtensionsTest {
     static func allTests() -> [(String, (ExtensionsTest) -> () -> Void)] {
-        var tests = [
+        let tests = [
             ("testBytes", testBytes),
             ("testToUInt32Array", testToUInt32Array),
             ("testDataInit", testDataInit),
@@ -111,11 +96,6 @@ extension ExtensionsTest {
             ("testArrayInitHex", testArrayInitHex),
         ]
 
-        #if !CI
-            tests += [
-                ("testArrayInitHexPerformance", testArrayInitHexPerformance),
-            ]
-        #endif
         return tests
     }
 }

+ 39 - 0
Tests/CryptoSwiftTests/ExtensionsTestPerf.swift

@@ -0,0 +1,39 @@
+//
+//  CryptoSwift
+//
+//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
+//  This software is provided 'as-is', without any express or implied warranty.
+//
+//  In no event will the authors be held liable for any damages arising from the use of this software.
+//
+//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
+//
+//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
+//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+//  - This notice may not be removed or altered from any source or binary distribution.
+//
+
+@testable import CryptoSwift
+import Foundation
+import XCTest
+
+final class ExtensionsTestPerf: XCTestCase {
+    func testArrayInitHexPerformance() {
+        var str = "b1b2b3b3b3b3b3b3b1b2b3b3b3b3b3b3"
+        for _ in 0...12 {
+            str += str
+        }
+        measure {
+            _ = Array<UInt8>(hex: str)
+        }
+    }
+}
+
+extension ExtensionsTestPerf {
+    static func allTests() -> [(String, (ExtensionsTestPerf) -> () -> Void)] {
+        let tests = [
+            ("testArrayInitHexPerformance", testArrayInitHexPerformance),
+        ]
+        return tests
+    }
+}

+ 1 - 15
Tests/CryptoSwiftTests/PBKDF.swift

@@ -58,27 +58,13 @@ class PBKDF: XCTestCase {
         XCTAssertEqual(value.toHexString(), "a53cf3df485e5cd9")
     }
 
-    #if !CI
-        func testPerformance() {
-            let password: Array<UInt8> = "s33krit".bytes
-            let salt: Array<UInt8> = "nacl".bytes
-            measure {
-                _ = try! PKCS5.PBKDF2(password: password, salt: salt, iterations: 65536, keyLength: 32, variant: .sha1).calculate()
-            }
-        }
-    #endif
-
     static func allTests() -> [(String, (PBKDF) -> () -> Void)] {
-        var tests = [
+        let tests = [
             ("testPBKDF1", testPBKDF1),
             ("testPBKDF2", testPBKDF2),
             ("testPBKDF2Length", testPBKDF2Length),
         ]
 
-        #if !CI
-            tests += [("testPerformance", testPerformance)]
-        #endif
-
         return tests
     }
 }

+ 32 - 0
Tests/CryptoSwiftTests/PBKDFPerf.swift

@@ -0,0 +1,32 @@
+//
+//  CryptoSwift
+//
+//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
+//  This software is provided 'as-is', without any express or implied warranty.
+//
+//  In no event will the authors be held liable for any damages arising from the use of this software.
+//
+//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
+//
+//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
+//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+//  - This notice may not be removed or altered from any source or binary distribution.
+//
+
+@testable import CryptoSwift
+import XCTest
+
+class PBKDFPerf: XCTestCase {
+    func testPerformance() {
+        let password: Array<UInt8> = "s33krit".bytes
+        let salt: Array<UInt8> = "nacl".bytes
+        measure {
+            _ = try! PKCS5.PBKDF2(password: password, salt: salt, iterations: 65536, keyLength: 32, variant: .sha1).calculate()
+        }
+    }
+
+    static func allTests() -> [(String, (PBKDFPerf) -> () -> Void)] {
+        let tests = [("testPerformance", testPerformance)]
+        return tests
+    }
+}

+ 1 - 18
Tests/CryptoSwiftTests/RabbitTests.swift

@@ -115,31 +115,14 @@ class RabbitTests: XCTestCase {
     }
 }
 
-#if !CI
-
-    extension RabbitTests {
-        func testRabbitPerformance() {
-            let key: Array<UInt8> = Array<UInt8>(repeating: 0, count: Rabbit.keySize)
-            let iv: Array<UInt8> = Array<UInt8>(repeating: 0, count: Rabbit.ivSize)
-            let message = Array<UInt8>(repeating: 7, count: (1024 * 1024) * 1)
-            measure {
-                _ = try! Rabbit(key: key, iv: iv).encrypt(message)
-            }
-        }
-    }
-#endif
-
 extension RabbitTests {
     static func allTests() -> [(String, (RabbitTests) -> () -> Void)] {
-        var tests = [
+        let tests = [
             ("testInitialization", testInitialization),
             ("testRabbitWithoutIV", testRabbitWithoutIV),
             ("testRabbitWithIV", testRabbitWithIV),
         ]
 
-        #if !CI
-            tests += [("testRabbitPerformance", testRabbitPerformance)]
-        #endif
         return tests
     }
 }

+ 37 - 0
Tests/CryptoSwiftTests/RabbitTestsPerf.swift

@@ -0,0 +1,37 @@
+//
+//  CryptoSwift
+//
+//  Copyright (C) 2014-2017 Marcin Krzyżanowski <marcin@krzyzanowskim.com>
+//  This software is provided 'as-is', without any express or implied warranty.
+//
+//  In no event will the authors be held liable for any damages arising from the use of this software.
+//
+//  Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
+//
+//  - The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required.
+//  - Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
+//  - This notice may not be removed or altered from any source or binary distribution.
+//
+
+@testable import CryptoSwift
+import XCTest
+
+class RabbitTestsPerf: XCTestCase {
+    func testRabbitPerformance() {
+        let key: Array<UInt8> = Array<UInt8>(repeating: 0, count: Rabbit.keySize)
+        let iv: Array<UInt8> = Array<UInt8>(repeating: 0, count: Rabbit.ivSize)
+        let message = Array<UInt8>(repeating: 7, count: (1024 * 1024) * 1)
+        measure {
+            _ = try! Rabbit(key: key, iv: iv).encrypt(message)
+        }
+    }
+}
+
+extension RabbitTestsPerf {
+    static func allTests() -> [(String, (RabbitTestsPerf) -> () -> Void)] {
+        let tests = [
+            ("testRabbitPerformance", testRabbitPerformance),
+        ]
+        return tests
+    }
+}

+ 15 - 2
Tests/LinuxMain.swift

@@ -1,7 +1,7 @@
 @testable import CryptoSwiftTests
 import XCTest
 
-XCTMain([
+var tests = [
     testCase(DigestTests.allTests()),
     testCase(Poly1305Tests.allTests),
     testCase(HMACTests.allTests),
@@ -15,4 +15,17 @@ XCTMain([
     testCase(PBKDF.allTests()),
     testCase(RandomBytesSequenceTests.allTests),
     testCase(Access.allTests),
-])
+]
+
+#if !CI
+    tests += [
+        testCase(DigestTestsPerf.allTests()),
+        testCase(AESTestsPerf.allTests()),
+        testCase(ChaCha20TestsPerf.allTests()),
+        testCase(RabbitTestsPerf.allTests()),
+        testCase(ExtensionsTestPerf.allTests()),
+        testCase(PBKDFPerf.allTests()),
+    ]
+#endif
+
+XCTMain(tests)