-
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.
perf(pluck,bufferTime,asObservable): add performance tests for pluck(…
…), bufferTime() and asObservable() operators (#2491) * perf(pluck,asobservable): add performance tests for pluck and asObservable operators * perf(bufferTime): add performance test for bufferTime operator
- Loading branch information
Showing
7 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
perf/micro/current-thread-scheduler/operators/asobservable.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,24 @@ | ||
var RxOld = require('rx'); | ||
var RxNew = require('../../../../index'); | ||
|
||
module.exports = function (suite) { | ||
var oldRangeWithImmediateScheduler = RxOld.Observable.range(0, 250, RxOld.Scheduler.currentThread); | ||
var newRangeWithImmediateScheduler = RxNew.Observable.range(0, 250, RxNew.Scheduler.queue); | ||
|
||
function _next(x) { } | ||
function _error(e) { } | ||
function _complete() { } | ||
return suite | ||
.add('old asObservable() with immediate scheduler', function () { | ||
var oldSubject = new RxOld.Subject(); | ||
|
||
oldSubject.asObservable().subscribe(_next, _error, _complete); | ||
oldRangeWithImmediateScheduler.subscribe(oldSubject); | ||
}) | ||
.add('new asObservable() with immediate scheduler', function () { | ||
var newSubject = new RxNew.Subject(); | ||
|
||
newSubject.asObservable().subscribe(_next, _error, _complete); | ||
newRangeWithImmediateScheduler.subscribe(newSubject); | ||
}); | ||
}; |
23 changes: 23 additions & 0 deletions
23
perf/micro/current-thread-scheduler/operators/pluck-nested.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,23 @@ | ||
var RxOld = require('rx'); | ||
var RxNew = require('../../../../index'); | ||
|
||
module.exports = function (suite) { | ||
var source = []; | ||
for (var i = 0; i < 25; i++) { | ||
source.push({'a': {'b': {'c': i }}}); | ||
} | ||
|
||
var oldPluckWithImmediateScheduler = RxOld.Observable.from(source, null, null, RxOld.Scheduler.currentThread).pluck('a', 'b', 'c'); | ||
var newPluckWithImmediateScheduler = RxNew.Observable.from(source, RxNew.Scheduler.queue).pluck('a', 'b', 'c'); | ||
|
||
function _next(x) { } | ||
function _error(e) { } | ||
function _complete() { } | ||
return suite | ||
.add('old pluck() with nested properties and current thread scheduler', function () { | ||
oldPluckWithImmediateScheduler.subscribe(_next, _error, _complete); | ||
}) | ||
.add('new pluck() with nested properties and current thread scheduler', function () { | ||
newPluckWithImmediateScheduler.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,23 @@ | ||
var RxOld = require('rx'); | ||
var RxNew = require('../../../../index'); | ||
|
||
module.exports = function (suite) { | ||
var source = []; | ||
for (var i = 0; i < 25; i++) { | ||
source.push({'p': i}); | ||
} | ||
|
||
var oldPluckWithImmediateScheduler = RxOld.Observable.from(source, null, null, RxOld.Scheduler.currentThread).pluck('p'); | ||
var newPluckWithImmediateScheduler = RxNew.Observable.from(source, RxNew.Scheduler.queue).pluck('p'); | ||
|
||
function _next(x) { } | ||
function _error(e) { } | ||
function _complete() { } | ||
return suite | ||
.add('old pluck() with current thread scheduler', function () { | ||
oldPluckWithImmediateScheduler.subscribe(_next, _error, _complete); | ||
}) | ||
.add('new pluck() with current thread scheduler', function () { | ||
newPluckWithImmediateScheduler.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,24 @@ | ||
var RxOld = require('rx'); | ||
var RxNew = require('../../../../index'); | ||
|
||
module.exports = function (suite) { | ||
var oldRangeWithImmediateScheduler = RxOld.Observable.range(0, 250, RxOld.Scheduler.immediate); | ||
var newRangeWithImmediateScheduler = RxNew.Observable.range(0, 250); | ||
|
||
function _next(x) { } | ||
function _error(e) { } | ||
function _complete() { } | ||
return suite | ||
.add('old asObservable() with immediate scheduler', function () { | ||
var oldSubject = new RxOld.Subject(); | ||
|
||
oldSubject.asObservable().subscribe(_next, _error, _complete); | ||
oldRangeWithImmediateScheduler.subscribe(oldSubject); | ||
}) | ||
.add('new asObservable() with immediate scheduler', function () { | ||
var newSubject = new RxNew.Subject(); | ||
|
||
newSubject.asObservable().subscribe(_next, _error, _complete); | ||
newRangeWithImmediateScheduler.subscribe(newSubject); | ||
}); | ||
}; |
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,18 @@ | ||
var RxOld = require('rx'); | ||
var RxNew = require('../../../../index'); | ||
|
||
module.exports = function (suite) { | ||
var oldBufferWithImmediateScheduler = RxOld.Observable.interval(25, RxOld.Scheduler.immediate).bufferWithTime(60, RxOld.Scheduler.immediate).take(3); | ||
var newBufferWithImmediateScheduler = RxNew.Observable.interval(25).bufferTime(60).take(3); | ||
|
||
function _next(x) { } | ||
function _error(e) { } | ||
function _complete() { } | ||
return suite | ||
.add('old bufferTime() with immediate scheduler', function () { | ||
oldBufferWithImmediateScheduler.subscribe(_next, _error, _complete); | ||
}) | ||
.add('new bufferTime() with immediate scheduler', function () { | ||
newBufferWithImmediateScheduler.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,23 @@ | ||
var RxOld = require('rx'); | ||
var RxNew = require('../../../../index'); | ||
|
||
module.exports = function (suite) { | ||
var source = []; | ||
for (var i = 0; i < 25; i++) { | ||
source.push({'a': {'b': {'c': i }}}); | ||
} | ||
|
||
var oldPluckWithImmediateScheduler = RxOld.Observable.from(source, null, null, RxOld.Scheduler.immediate).pluck('a', 'b', 'c'); | ||
var newPluckWithImmediateScheduler = RxNew.Observable.from(source).pluck('a', 'b', 'c'); | ||
|
||
function _next(x) { } | ||
function _error(e) { } | ||
function _complete() { } | ||
return suite | ||
.add('old pluck() with nested properties and immediate scheduler', function () { | ||
oldPluckWithImmediateScheduler.subscribe(_next, _error, _complete); | ||
}) | ||
.add('new pluck() with nested properties and immediate scheduler', function () { | ||
newPluckWithImmediateScheduler.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,23 @@ | ||
var RxOld = require('rx'); | ||
var RxNew = require('../../../../index'); | ||
|
||
module.exports = function (suite) { | ||
var source = []; | ||
for (var i = 0; i < 25; i++) { | ||
source.push({'p': i}); | ||
} | ||
|
||
var oldPluckWithImmediateScheduler = RxOld.Observable.from(source, null, null, RxOld.Scheduler.immediate).pluck('p'); | ||
var newPluckWithImmediateScheduler = RxNew.Observable.from(source).pluck('p'); | ||
|
||
function _next(x) { } | ||
function _error(e) { } | ||
function _complete() { } | ||
return suite | ||
.add('old pluck() with immediate scheduler', function () { | ||
oldPluckWithImmediateScheduler.subscribe(_next, _error, _complete); | ||
}) | ||
.add('new pluck() with immediate scheduler', function () { | ||
newPluckWithImmediateScheduler.subscribe(_next, _error, _complete); | ||
}); | ||
}; |