• Stars
    star
    187
  • Rank 206,464 (Top 5 %)
  • Language
    Swift
  • Created over 5 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A test suite comparing the performance of Combine and RxSwift

Combine vs. RxSwift Performance Benchmark Test Suite 📊

This project contains a benchmarking test suite for comparing the performance of the most commonly used components and operators in RxSwift and Combine. For a detailed comparison of RxSwift with Combine have a look at our blog post.

The RxSwift performance benchmark tests are the original ones used in the RxSwift project. We removed the two tests from RxCocoa testing Drivers, since there is no equivalent in Combine. The Combine tests are 1:1 translated tests from the Rx test-suite and should, therefore, be easily comparable.

Important update: As mentioned correctly the old numbers were created with XCTests running in DEBUG mode. The differences seem not so critical in Release builds. We have updated all the numbers and graphs to use release builds.

As a summary Combine was faster in every test and on average 41% more performant than RxSwift. These statistics show every test-method and its results. Lower is better.

Test Results Summary

Test RxSwift (ms) Combine (ms) Factor
PublishSubjectPumping 227 135 168%
PublishSubjectPumpingTwoSubscriptions 400 246 163%
PublishSubjectCreating 295 250 118%
MapFilterPumping 123 132 93%
MapFilterCreating 168 114 147%
FlatMapsPumping 646 367 176%
FlatMapsCreating 214 121 177%
FlatMapLatestPumping 810 696 116%
FlatMapLatestCreating 263 180 146%
CombineLatestPumping 298 282 106%
CombineLatestCreating 644 467 138%

Testing Details

Machine: MacBook Pro 2018, 2,7 GHz Intel Core i7, 16 GB IDE: Xcode 11.0 beta 5 (11M382q) Testing Device: iPhone XR Simulator

Performance Test Example: PublishSubject Pumping

For every test we replace the RxSwift component with the corresponding Combine component. In this case PublishSubject with PassthroughSubject.

RxSwift

func testPublishSubjectPumping() {
    measure {
        var sum = 0
        let subject = PublishSubject<Int>()

        let subscription = subject
            .subscribe(onNext: { x in
                sum += x
            })

        for _ in 0 ..< iterations * 100 {
            subject.on(.next(1))
        }

        subscription.dispose()

        XCTAssertEqual(sum, iterations * 100)
    }
}

Combine

func testPublishSubjectPumping() {
    measure {
        var sum = 0
        let subject = PassthroughSubject<Int, Never>()

        let subscription = subject
            .sink(receiveValue: { x in
                sum += x
            })

        for _ in 0 ..< iterations * 100 {
            subject.send(1)
        }
        
        subscription.cancel()
        
        XCTAssertEqual(sum, iterations * 100)
    }
}

Detailed Performance Test Results: RxSwift vs. Combine

PublishSubjectPumping

PublishSubjectPumpingTwoSubscriptions

PublishSubjectCreating

MapFilterPumping

MapFilterCreating

FlatMapsPumping

FlatMapsCreating

FlatMapLatestPumping

FlatMapLatestCreating

CombineLatestPumping

CombineLatestCreating

More Repositories

1

XCoordinator

🎌 Powerful navigation library for iOS based on the coordinator pattern
Swift
2,253
star
2

FlippingNotch

FlippingNotch 🤙 - Dribble inspired animation https://dribbble.com/shots/4089014-Pull-To-Refresh-iPhone-X
Swift
835
star
3

SwiftUI-Architectures

Three different architectures (Model-View, Redux, MVVM) for using SwiftUI implemented at the example of a chat app
Swift
682
star
4

opencv-android

Easy way to integrate OpenCv into your Android project via Gradle
Kotlin
673
star
5

PullToReach

PullToReach is a simple drag-and-drop solution for adding pull-to-reach functionality to your app
Swift
516
star
6

SurveyKit

Android library to create beautiful surveys (aligned with ResearchKit on iOS)
Kotlin
386
star
7

SwiftUI-Coordinators-Example

Sample app that showcases the use of the Coordinator Pattern in SwiftUI
Swift
223
star
8

survey_kit

Flutter library to create beautiful surveys (aligned with ResearchKit on iOS)
Dart
124
star
9

XUI

XUI makes modular, testable architectures for SwiftUI apps a breeze!
Swift
116
star
10

XCoordinator-Example

XCoordinator-Example serves as an MVVM-C example app for XCoordinator
Swift
64
star
11

kotlin-snapshot-testing

Extensible Kotlin Multiplatform library to easily create Snapshot tests for Android and other Kotlin applications
Kotlin
61
star
12

XServiceLocator

Light-weight Service Locator / Dependency Injection library for Swift: providing objects with the dependencies they need throughout your whole iOS app.
Swift
54
star
13

yuvToMat

High-performance library for converting YUV_420_888 Android Camera images to OpenCV RGB Mats
Kotlin
53
star
14

NonEmptyCollections

A type-safe implementation for collections that cannot be empty. Life is too short for emptiness-checks!
Kotlin
53
star
15

DataKit

A Swift library to easily read and write binary formatted data using a modern, declarative interface.
Swift
42
star
16

flutter_platform_search

A platform-adaptive search for Flutter
Dart
36
star
17

flutter_pull_to_reach_demo

A new way to access controls in your flutter app that are normally hard to reach with your thumb
Dart
26
star
18

QBRepository

QBRepository is a simple implementation of the repository pattern for data access in Swift
Swift
16
star
19

DependencyInjectionPlayground

Playground showing different techniques for dependency injection in Swift
Swift
15
star
20

platform-independent-mvvm-android

An Android-MVVM example of how we create platform-independent ViewModels that can be reused on iOS/Desktop/Server
Kotlin
13
star
21

crc-swift

Swift
11
star
22

XCoordinator-Talks

Presentations & Workshops about the Coordinator pattern & XCoordinator
Swift
6
star
23

crc-kotlin

Kotlin
5
star
24

DoggyKotlinKoans

A list of entertaining koans/exercises to learn the basic features of Kotlin (including solutions).
Kotlin
3
star
25

mobile_hacknight_flutter

Dart
3
star
26

actions

JavaScript
2
star
27

HackNight-SwiftUI

Swift
1
star