-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(micro-perf): add perf tests for switchMapTo
Results on a Intel Core i7-3770 (Ivy Bridge) running Ubuntu: | RxJS 4.0.7 | RxJS 5.0.0-beta.1 | factor | % improved -------------------------------------------------------------------------------------------------- switchmapto-resultselector - immediate | 1,695 (±1.02%) | 12,229 (±1.15%) | 7.21x | 621.3% switchmapto - immediate | 2,910 (±0.80%) | 32,560 (±0.99%) | 11.19x | 1,018.8% switchmapto-resultselector | 2,621 (±0.87%) | 12,473 (±0.49%) | 4.76x | 375.9% switchmapto | 3,300 (±2.11%) | 15,433 (±0.57%) | 4.68x | 367.7%
- Loading branch information
1 parent
2878aed
commit 8359af9
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
perf/micro/current-thread-scheduler/operators/switchmapto-resultselector.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var RxOld = require('rx'); | ||
var RxNew = require('../../../../index'); | ||
|
||
module.exports = function (suite) { | ||
var resultSelector = function (x, y, ix, iy) { return x + y + ix + iy; }; | ||
var oldSwitchMapToWithCurrentThreadScheduler = RxOld.Observable.range(0, 25, RxOld.Scheduler.currentThread) | ||
.flatMapLatest(RxOld.Observable.range(0, 10, RxOld.Scheduler.currentThread), resultSelector); | ||
var newSwitchMapToWithCurrentThreadScheduler = RxNew.Observable.range(0, 25, RxNew.Scheduler.queue) | ||
.switchMapTo(RxNew.Observable.range(0, 10, RxNew.Scheduler.queue), resultSelector); | ||
|
||
function _next(x) { } | ||
function _error(e) { } | ||
function _complete() { } | ||
return suite | ||
.add('old switchMapTo with resultSelector and current thread scheduler', function () { | ||
oldSwitchMapToWithCurrentThreadScheduler.subscribe(_next, _error, _complete); | ||
}) | ||
.add('new switchMapTo with resultSelector and current thread scheduler', function () { | ||
newSwitchMapToWithCurrentThreadScheduler.subscribe(_next, _error, _complete); | ||
}); | ||
}; |
20 changes: 20 additions & 0 deletions
20
perf/micro/current-thread-scheduler/operators/switchmapto.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var RxOld = require('rx'); | ||
var RxNew = require('../../../../index'); | ||
|
||
module.exports = function (suite) { | ||
var oldSwitchMapToWithCurrentThreadScheduler = RxOld.Observable.range(0, 25, RxOld.Scheduler.currentThread) | ||
.flatMapLatest(RxOld.Observable.range(0, 10, RxOld.Scheduler.currentThread)); | ||
var newSwitchMapToWithCurrentThreadScheduler = RxNew.Observable.range(0, 25, RxNew.Scheduler.queue) | ||
.switchMapTo(RxNew.Observable.range(0, 10, RxNew.Scheduler.queue)); | ||
|
||
function _next(x) { } | ||
function _error(e) { } | ||
function _complete() { } | ||
return suite | ||
.add('old switchMapTo with current thread scheduler', function () { | ||
oldSwitchMapToWithCurrentThreadScheduler.subscribe(_next, _error, _complete); | ||
}) | ||
.add('new switchMapTo with current thread scheduler', function () { | ||
newSwitchMapToWithCurrentThreadScheduler.subscribe(_next, _error, _complete); | ||
}); | ||
}; |
21 changes: 21 additions & 0 deletions
21
perf/micro/immediate-scheduler/operators/switchmapto-resultselector.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var RxOld = require('rx'); | ||
var RxNew = require('../../../../index'); | ||
|
||
module.exports = function (suite) { | ||
var resultSelector = function (x, y, ix, iy) { return x + y + ix + iy; }; | ||
var oldSwitchMapToWithImmediateScheduler = RxOld.Observable.range(0, 25, RxOld.Scheduler.immediate) | ||
.flatMapLatest(RxOld.Observable.range(0, 10, RxOld.Scheduler.immediate), resultSelector); | ||
var newSwitchMapToWithImmediateScheduler = RxNew.Observable.range(0, 25) | ||
.switchMapTo(RxNew.Observable.range(0, 10), resultSelector); | ||
|
||
function _next(x) { } | ||
function _error(e) { } | ||
function _complete() { } | ||
return suite | ||
.add('old switchMapTo with resultSelector and immediate scheduler', function () { | ||
oldSwitchMapToWithImmediateScheduler.subscribe(_next, _error, _complete); | ||
}) | ||
.add('new switchMapTo with resultSelector and immediate scheduler', function () { | ||
newSwitchMapToWithImmediateScheduler.subscribe(_next, _error, _complete); | ||
}); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var RxOld = require('rx'); | ||
var RxNew = require('../../../../index'); | ||
|
||
module.exports = function (suite) { | ||
var oldSwitchMapToWithImmediateScheduler = RxOld.Observable.range(0, 25, RxOld.Scheduler.immediate) | ||
.flatMapLatest(RxOld.Observable.range(0, 10, RxOld.Scheduler.immediate)); | ||
var newSwitchMapToWithImmediateScheduler = RxNew.Observable.range(0, 25) | ||
.switchMapTo(RxNew.Observable.range(0, 10)); | ||
|
||
function _next(x) { } | ||
function _error(e) { } | ||
function _complete() { } | ||
return suite | ||
.add('old switchMapTo with immediate scheduler', function () { | ||
oldSwitchMapToWithImmediateScheduler.subscribe(_next, _error, _complete); | ||
}) | ||
.add('new switchMapTo with immediate scheduler', function () { | ||
newSwitchMapToWithImmediateScheduler.subscribe(_next, _error, _complete); | ||
}); | ||
}; |