diff --git a/RxTests/PerformanceTests/main.swift b/RxTests/PerformanceTests/main.swift index 53ce2b89..57d74db5 100644 --- a/RxTests/PerformanceTests/main.swift +++ b/RxTests/PerformanceTests/main.swift @@ -9,6 +9,8 @@ import Foundation import RxSwift import RxCocoa +import AppKit +import CoreLocation let NumberOfIterations = 1000 @@ -45,13 +47,24 @@ func measureMemoryUsage(@noescape work: () -> ()) -> (bytesAllocated: UInt64, al return (approxValuePerIteration(bytesAfter - bytes), approxValuePerIteration(allocationsAfter - allocations)) } +let bechmarkTime = true + func compareTwoImplementations(@noescape first first: () -> (), @noescape second: () -> ()) { // first warm up to keep it fair first() second() - let time1 = measureTime(first) - let time2 = measureTime(second) + let time1: UInt64 + let time2: UInt64 + + if bechmarkTime { + time1 = measureTime(first) + time2 = measureTime(second) + } + else { + time1 = 0 + time2 = 0 + } registerMallocHooks() @@ -72,6 +85,18 @@ func compareTwoImplementations(@noescape first first: () -> (), @noescape second } compareTwoImplementations(first: { + let publishSubject = PublishSubject() + + publishSubject + .shareReplay(1) + .subscribeNext { _ in + + } + + + for i in 0..<100 { + publishSubject.on(.Next(i)) + } }, second: { diff --git a/RxTests/RxTests.xcodeproj/project.pbxproj b/RxTests/RxTests.xcodeproj/project.pbxproj index 0feddd04..97e01155 100644 --- a/RxTests/RxTests.xcodeproj/project.pbxproj +++ b/RxTests/RxTests.xcodeproj/project.pbxproj @@ -51,6 +51,8 @@ C836EA081B8A76CD00AB941D /* RxSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C836EA001B8A76A900AB941D /* RxSwift.framework */; }; C84B8FC21B89D0D500C9CCCF /* BagTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C84B8FC11B89D0D500C9CCCF /* BagTest.swift */; }; C84B8FC31B89D0D500C9CCCF /* BagTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C84B8FC11B89D0D500C9CCCF /* BagTest.swift */; }; + C84CC4E91BDADA0B00E06A64 /* RxSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C836EA001B8A76A900AB941D /* RxSwift.framework */; }; + C84CC4EB1BDAEDF700E06A64 /* RxCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C84CC4EA1BDAEDF700E06A64 /* RxCocoa.framework */; }; C85F4E431B7F70EA00A866C7 /* CompositeObserverTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85F4E421B7F70EA00A866C7 /* CompositeObserverTest.swift */; }; C85F4E441B7F70EA00A866C7 /* CompositeObserverTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85F4E421B7F70EA00A866C7 /* CompositeObserverTest.swift */; }; C8633AE51B0A9FF300375D60 /* KVOObservableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8633AE41B0A9FF300375D60 /* KVOObservableTests.swift */; }; @@ -217,6 +219,8 @@ C81CC92A1B513FD400915606 /* NSObject+RxTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSObject+RxTests.swift"; sourceTree = ""; }; C836EA001B8A76A900AB941D /* RxSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = RxSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; C84B8FC11B89D0D500C9CCCF /* BagTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BagTest.swift; sourceTree = ""; }; + C84CC4E71BDAD9FF00E06A64 /* RxBlocking.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxBlocking.framework; path = ../build/Debug/RxBlocking.framework; sourceTree = ""; }; + C84CC4EA1BDAEDF700E06A64 /* RxCocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxCocoa.framework; path = ../build/Debug/RxCocoa.framework; sourceTree = ""; }; C85F4E421B7F70EA00A866C7 /* CompositeObserverTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CompositeObserverTest.swift; sourceTree = ""; }; C8633AE41B0A9FF300375D60 /* KVOObservableTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KVOObservableTests.swift; sourceTree = ""; }; C868D0F81BB76A29003D1474 /* PerformanceTools.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PerformanceTools.swift; sourceTree = ""; }; @@ -262,6 +266,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + C84CC4EB1BDAEDF700E06A64 /* RxCocoa.framework in Frameworks */, + C84CC4E91BDADA0B00E06A64 /* RxSwift.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -291,6 +297,8 @@ C81108151AF50DDA001C13E4 = { isa = PBXGroup; children = ( + C84CC4EA1BDAEDF700E06A64 /* RxCocoa.framework */, + C84CC4E71BDAD9FF00E06A64 /* RxBlocking.framework */, C8A468CE1B8A897D00BF917B /* RxBlocking.framework */, C8A468CC1B8A897800BF917B /* RxCocoa.framework */, C836EA001B8A76A900AB941D /* RxSwift.framework */,