Skip to content

Commit 1abdd10

Browse files
luisgabrielkwonoj
authored andcommitted
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%
1 parent 66c526e commit 1abdd10

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var RxOld = require('rx');
2+
var RxNew = require('../../../../index');
3+
4+
module.exports = function (suite) {
5+
var resultSelector = function (x, y, ix, iy) { return x + y + ix + iy; };
6+
var oldSwitchMapToWithCurrentThreadScheduler = RxOld.Observable.range(0, 25, RxOld.Scheduler.currentThread)
7+
.flatMapLatest(RxOld.Observable.range(0, 10, RxOld.Scheduler.currentThread), resultSelector);
8+
var newSwitchMapToWithCurrentThreadScheduler = RxNew.Observable.range(0, 25, RxNew.Scheduler.queue)
9+
.switchMapTo(RxNew.Observable.range(0, 10, RxNew.Scheduler.queue), resultSelector);
10+
11+
function _next(x) { }
12+
function _error(e) { }
13+
function _complete() { }
14+
return suite
15+
.add('old switchMapTo with resultSelector and current thread scheduler', function () {
16+
oldSwitchMapToWithCurrentThreadScheduler.subscribe(_next, _error, _complete);
17+
})
18+
.add('new switchMapTo with resultSelector and current thread scheduler', function () {
19+
newSwitchMapToWithCurrentThreadScheduler.subscribe(_next, _error, _complete);
20+
});
21+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var RxOld = require('rx');
2+
var RxNew = require('../../../../index');
3+
4+
module.exports = function (suite) {
5+
var oldSwitchMapToWithCurrentThreadScheduler = RxOld.Observable.range(0, 25, RxOld.Scheduler.currentThread)
6+
.flatMapLatest(RxOld.Observable.range(0, 10, RxOld.Scheduler.currentThread));
7+
var newSwitchMapToWithCurrentThreadScheduler = RxNew.Observable.range(0, 25, RxNew.Scheduler.queue)
8+
.switchMapTo(RxNew.Observable.range(0, 10, RxNew.Scheduler.queue));
9+
10+
function _next(x) { }
11+
function _error(e) { }
12+
function _complete() { }
13+
return suite
14+
.add('old switchMapTo with current thread scheduler', function () {
15+
oldSwitchMapToWithCurrentThreadScheduler.subscribe(_next, _error, _complete);
16+
})
17+
.add('new switchMapTo with current thread scheduler', function () {
18+
newSwitchMapToWithCurrentThreadScheduler.subscribe(_next, _error, _complete);
19+
});
20+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var RxOld = require('rx');
2+
var RxNew = require('../../../../index');
3+
4+
module.exports = function (suite) {
5+
var resultSelector = function (x, y, ix, iy) { return x + y + ix + iy; };
6+
var oldSwitchMapToWithImmediateScheduler = RxOld.Observable.range(0, 25, RxOld.Scheduler.immediate)
7+
.flatMapLatest(RxOld.Observable.range(0, 10, RxOld.Scheduler.immediate), resultSelector);
8+
var newSwitchMapToWithImmediateScheduler = RxNew.Observable.range(0, 25)
9+
.switchMapTo(RxNew.Observable.range(0, 10), resultSelector);
10+
11+
function _next(x) { }
12+
function _error(e) { }
13+
function _complete() { }
14+
return suite
15+
.add('old switchMapTo with resultSelector and immediate scheduler', function () {
16+
oldSwitchMapToWithImmediateScheduler.subscribe(_next, _error, _complete);
17+
})
18+
.add('new switchMapTo with resultSelector and immediate scheduler', function () {
19+
newSwitchMapToWithImmediateScheduler.subscribe(_next, _error, _complete);
20+
});
21+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var RxOld = require('rx');
2+
var RxNew = require('../../../../index');
3+
4+
module.exports = function (suite) {
5+
var oldSwitchMapToWithImmediateScheduler = RxOld.Observable.range(0, 25, RxOld.Scheduler.immediate)
6+
.flatMapLatest(RxOld.Observable.range(0, 10, RxOld.Scheduler.immediate));
7+
var newSwitchMapToWithImmediateScheduler = RxNew.Observable.range(0, 25)
8+
.switchMapTo(RxNew.Observable.range(0, 10));
9+
10+
function _next(x) { }
11+
function _error(e) { }
12+
function _complete() { }
13+
return suite
14+
.add('old switchMapTo with immediate scheduler', function () {
15+
oldSwitchMapToWithImmediateScheduler.subscribe(_next, _error, _complete);
16+
})
17+
.add('new switchMapTo with immediate scheduler', function () {
18+
newSwitchMapToWithImmediateScheduler.subscribe(_next, _error, _complete);
19+
});
20+
};

0 commit comments

Comments
 (0)