Skip to content

Commit

Permalink
chore(distinct): add perf tests for distinct
Browse files Browse the repository at this point in the history
- Current performance is sub-par, 60% of the speed of Rx 4's operator.
  • Loading branch information
benlesh committed Jan 27, 2016
1 parent fe4d57f commit e97fc7b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions perf/micro/immediate-scheduler/operators/distinct-keyselector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var RxOld = require('rx');
var RxNew = require('../../../../dist/cjs/Rx.KitchenSink');

module.exports = function (suite) {
var source = Array.from({ length: 25 }, function (_, i) { return { value: i % 3 }; });
var _old = RxOld.Observable.fromArray(source).distinct(function (x) { return x.value; });
var _new = RxNew.Observable.fromArray(source).distinct(function (x) { return x.value; });

function _next(x) { }
function _error(e) { }
function _complete() { }
return suite
.add('old count with immediate scheduler', function () {
_old.subscribe(_next, _error, _complete);
})
.add('new count with immediate scheduler', function () {
_new.subscribe(_next, _error, _complete);
});
};
19 changes: 19 additions & 0 deletions perf/micro/immediate-scheduler/operators/distinct.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var RxOld = require('rx');
var RxNew = require('../../../../dist/cjs/Rx.KitchenSink');

module.exports = function (suite) {
var source = Array.from({ length: 25 }, function (_, i) { return i % 3; });
var _old = RxOld.Observable.fromArray(source).distinct();
var _new = RxNew.Observable.fromArray(source).distinct();

function _next(x) { }
function _error(e) { }
function _complete() { }
return suite
.add('old count with immediate scheduler', function () {
_old.subscribe(_next, _error, _complete);
})
.add('new count with immediate scheduler', function () {
_new.subscribe(_next, _error, _complete);
});
};

0 comments on commit e97fc7b

Please sign in to comment.