From ee0b24db3ae8e3621abc6a87b03b574bd5bccc09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Gabriel=20Lima?= Date: Wed, 10 Feb 2016 17:20:06 -0300 Subject: [PATCH] chore(micro-perf): add perf tests for retry with queue scheduler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Results on a Intel Core i7-3770 (Ivy Bridge) running Ubuntu: | RxJS 4.0.7 | RxJS 5.0.0-beta.1 | factor | % improved ------------------------------------------------------------------------------ retry - immediate | 41,067 (±1.04%) | 179,337 (±1.10%) | 4.37x | 336.7% retry | 33,846 (±1.19%) | 97,202 (±0.62%) | 2.87x | 187.2% --- .../operators/retry.js | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 perf/micro/current-thread-scheduler/operators/retry.js diff --git a/perf/micro/current-thread-scheduler/operators/retry.js b/perf/micro/current-thread-scheduler/operators/retry.js new file mode 100644 index 0000000000..e694e3ac5d --- /dev/null +++ b/perf/micro/current-thread-scheduler/operators/retry.js @@ -0,0 +1,35 @@ +var RxOld = require('rx'); +var RxNew = require('../../../../index'); + +module.exports = function (suite) { + var maxRetryCount = 25; + var oldRetryCount = 0; + var newRetryCount = 0; + + var _old = RxOld.Observable.ofWithScheduler(RxOld.Scheduler.currentThread, 5) + .flatMap(function (x) { + if (++oldRetryCount < maxRetryCount - 1) { + return RxOld.Observable.throw(new Error('error'), RxOld.Scheduler.currentThread); + } + return RxOld.Observable.ofWithScheduler(RxOld.Scheduler.currentThread, x); + }).retry(maxRetryCount); + + var _new = RxNew.Observable.of(5, RxNew.Scheduler.queue) + .mergeMap(function (x) { + if (++newRetryCount < maxRetryCount - 1) { + return RxNew.Observable.throw(new Error('error'), RxNew.Scheduler.queue); + } + return RxNew.Observable.of(x, RxNew.Scheduler.queue); + }).retry(maxRetryCount); + + function _next(x) { } + function _error(e) { } + function _complete() { } + return suite + .add('old retry with currentThread scheduler', function () { + _old.subscribe(_next, _error, _complete); + }) + .add('new retry with currentThread scheduler', function () { + _new.subscribe(_next, _error, _complete); + }); +};