Created
April 17, 2017 07:54
-
-
Save andersio/1f3a118c88dc17e602d0b0a2abd191a9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import XCTest | |
| import ReactiveSwift | |
| import Result | |
| class Test: XCTestCase { | |
| func testPerformanceExample() { | |
| let (signal, observer) = Signal<Int, NoError>.pipe() | |
| let transformed = signal | |
| .map { $0 + Int(arc4random() % 5 as UInt32) } | |
| .map { $0 + Int(arc4random() % 4 as UInt32) } | |
| .map { $0 + Int(arc4random() % 3 as UInt32) } | |
| .map { $0 + Int(arc4random() % 2 as UInt32) } | |
| var values: [Int] = [] | |
| transformed.observeValues { value in | |
| if !values.contains(value) { | |
| values.append(value) | |
| } | |
| } | |
| self.measure { | |
| for _ in 1 ... 10000 { | |
| observer.send(value: Int(arc4random() % 5) - 4) | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment