                 item.succeed(value: 1)
             }
         }
-
-        wait() // wait so that next test aren't affecteds
-    }
-
-    func testAttachingCallbacksToResolvedFuture() {
-        let futures = Array(0..<10000).map { _ in
-            return Future(value: 1)
-        }
-
-        measure {
-            for future in futures {
-                future.on(success: { _ in })
-            }
-        }
-    }
-
-    // MARK: - Fulfilling From Multiple Threads
-
-    func testResolveFromMultipleThreads() {
+    }
+
+    func testSucceedWithTwoCallback() {
+        let items = (0..<100_000).map { _ in Promise<Int, Void>() }
+
+        for item in items {
+            item.future.on(success: { _ in })
+            item.future.on(success: { _ in })
+        }
+
+        measure {
+            for item in items {
+                item.succeed(value: 1)
+            }
+        }
+    }
+
+    func testSucceedFromMultipleThreads() {
         let promises = Array(0..<10).map { _ in
             Array(0..<10000).map { _ in
                 Promise<Int, Never>()

import Foundation
import Future

class PromisePerformanceTests: XCTestCase {

    // MARK: - Init

    func testInit() {
        measure {
            for _ in 0..<100_000 {
                let _ = Future<Int, Void> { _ in

            }
        }
    }
}

class FutureCallbacksTests: XCTestCase {

    func testAttachCallbacksToResolved() {
        let futures = (0..<50_000).map { _ in Future(value: 1) }

        measure {
            for future in futures {
                future.on(success: { _ in },
                          failure: { _ in },
                          completion: { _ in })
            }
        }
    }

    func testAttachCallbacksToResolvedConcurrently() {
        let futures = Array(0..<10).map { _ in
            Array(0..<10000).map { _ in
                Future(value: 1)
            }
        }

        measure {
            DispatchQueue.concurrentPerform(iterations: 10) { iteration in
                for future in futures[iteration] {
                    future.on(success: { _ in },
                              failure: { _ in },
                              completion: { _ in })
                }
            }
        }
    }

    func testAttachCallbacksToPending() {
        let futures = (0..<50_000).map { _ in Promise<Int, Never>().future }

        measure {
            for future in futures {
                future.on(success: { _ in },
                          failure: { _ in },
                          completion: { _ in })
            }
        }
    }

    func testAttachCallbacksToPendingTwoTimes() {
        let futures = (0..<50_000).map { _ in Promise<Int, Never>().future }

        measure {
            for future in futures {
                future.on(success: { _ in },
                          failure: { _ in },
                          completion: { _ in })

                future.on(success: { _ in },
                          failure: { _ in },
                          completion: { _ in })
            }
        }
    }

    func testAttachCallbacksToPendingConcurrently() {
        let futures = Array(0..<10).map { _ in
            Array(0..<10000).map { _ in
                Promise<Int, Never>().future
            }
        }

        measure {
            DispatchQueue.concurrentPerform(iterations: 10) { iteration in
                for future in futures[iteration] {
                    future.on(success: { _ in },
                              failure: { _ in },
                              completion: { _ in })
                }
            }
        }
    }
}

class PromiseResolveTests: XCTestCase {

    func testSucceedWithOneCallback() {
        let items = (0..<100_000).map { _ in Promise<Int, Void>() }

        for item in items {
            item.future.on(success: { _ in })
        }

        measure {
