Skip to content

Commit

Permalink
chore(test): add micro-benchmark performance test for Observable.throw
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj authored and benlesh committed Sep 3, 2015
1 parent c39a245 commit 492f594
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
20 changes: 20 additions & 0 deletions perf/micro/current-thread-scheduler/observable/throw.js
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 _throw(suite) {

var oldThrowWithCurrentThreadScheduler = RxOld.Observable.throw(new Error('error'), RxOld.Scheduler.currentThread);
var newThrowWithCurrentThreadScheduler = RxNew.Observable.throw(new Error('error'), RxNew.Scheduler.immediate);

// add tests
return suite
.add('old throw with current thread scheduler', function () {
oldThrowWithCurrentThreadScheduler.subscribe(_next, _error, _complete);
})
.add('new throw with current thread scheduler', function () {
newThrowWithCurrentThreadScheduler.subscribe(_next, _error, _complete);
});
function _next(x) { }
function _error(e){ }
function _complete(){ }
};
20 changes: 20 additions & 0 deletions perf/micro/immediate-scheduler/observable/throw.js
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 _throw(suite) {

var oldThrowWithImmediateScheduler = RxOld.Observable.throw(new Error('error'), RxOld.Scheduler.immediate);
var newThrowWithImmediateScheduler = RxNew.Observable.throw(new Error('error'));

// add tests
return suite
.add('old throw with immediate scheduler', function () {
oldThrowWithImmediateScheduler.subscribe(_next, _error, _complete);
})
.add('new throw with immediate scheduler', function () {
newThrowWithImmediateScheduler.subscribe(_next, _error, _complete);
});
function _next(x) { }
function _error(e){ }
function _complete(){ }
};
2 changes: 2 additions & 0 deletions perf/micro/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Observable.from([
require("./immediate-scheduler/observable/from-with-string"),
require("./immediate-scheduler/observable/of"),
require("./immediate-scheduler/observable/range"),
require("./immediate-scheduler/observable/throw"),

require("./immediate-scheduler/operators/combine-latest"),
require("./immediate-scheduler/operators/concat"),
Expand Down Expand Up @@ -40,6 +41,7 @@ Observable.from([
require("./current-thread-scheduler/observable/from-with-string"),
require("./current-thread-scheduler/observable/of"),
require("./current-thread-scheduler/observable/range"),
require("./current-thread-scheduler/observable/throw"),

require("./current-thread-scheduler/operators/combine-latest"),
require("./current-thread-scheduler/operators/concat"),
Expand Down

0 comments on commit 492f594

Please sign in to comment.