<commit_before>var RxOld = require('rx');
var RxNew = require('../../../../index');

module.exports = function (suite) {
  var maxRetryCount = 25;
  var oldRetryCount = 0;
  var newRetryCount = 0;

  var oldRetryWithImmediateScheduler = RxOld.Observable.of(5, RxOld.Scheduler.immediate)
    .flatMap(function (x) {
      if (++oldRetryCount < maxRetryCount - 1) {
        return RxOld.Observable.throw(new Error('error'),  RxOld.Scheduler.immediate);
      }
      return RxOld.Observable.of(x, RxOld.Scheduler.immediate);
    }).retry(maxRetryCount);
  var newRetryWithImmediateScheduler = RxNew.Observable.of(5)
    .mergeMap(function (x) {
      if (++newRetryCount < maxRetryCount - 1) {
        return RxNew.Observable.throw(new Error('error'));
      }
      return RxNew.Observable.of(x);
    }).retry(maxRetryCount);

  function _next(x) { }
  function _error(e) { }
  function _complete() { }
  return suite
      .add('old retry with immediate scheduler', function () {
        oldRetryWithImmediateScheduler.subscribe(_next, _error, _complete);
      })
      .add('new retry with immediate scheduler', function () {
        newRetryWithImmediateScheduler.subscribe(_next, _error, _complete);
      });
};<commit_msg>chore(micro-perf): fix scheduling of retry perf test<commit_after>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.immediate, 5)
    .flatMap(function (x) {
      if (++oldRetryCount < maxRetryCount - 1) {
        return RxOld.Observable.throw(new Error('error'),  RxOld.Scheduler.immediate);
      }
      return RxOld.Observable.ofWithScheduler(RxOld.Scheduler.immediate, x);
    }).retry(maxRetryCount);

  var _new = RxNew.Observable.of(5)
    .mergeMap(function (x) {
      if (++newRetryCount < maxRetryCount - 1) {
        return RxNew.Observable.throw(new Error('error'));
      }
      return RxNew.Observable.of(x);
    }).retry(maxRetryCount);

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

{'fraction_non_alphanumeric': 0.14220752377015294, 'fraction_numerical': 0.006614303431169905, 'mean_word_length': 3.26056338028169, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1881806', 'n_tokens_mistral': 802, 'n_tokens_neox': 787, 'n_words': 160}