Skip to content

Commit

Permalink
refactor(test): let macro perf test use range to create observables
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj authored and benlesh committed Sep 11, 2015
1 parent 218f629 commit ca42a32
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 56 deletions.
17 changes: 2 additions & 15 deletions perf/macro/flatMap-scalar/perf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,8 @@ var RxNextFlatMapRange = document.querySelector('#rx-3-flatmap-range-to-scalar')
var Rx2ObservableReturn = Rx.Observable.return;
var RxNextObservableReturn = RxNext.Observable.of;

var RxNextTestObservable = new RxNext.Observable(function(observer) {
var index = -1;
while(++index < numIterations) {
observer.next(index);
}
observer.complete();
});

var Rx2TestObservable = Rx.Observable.create(function(observer) {
var index = -1;
while(++index < numIterations) {
observer.onNext(index);
}
observer.onCompleted();
});
var RxNextTestObservable = RxNext.Observable.range(0, numIterations);
var Rx2TestObservable = Rx.Observable.range(0, numIterations);

Rx2FlatMapRange.addEventListener('click', function() {
Rx2TestObservable.flatMap(projectionRx2).subscribe();
Expand Down
17 changes: 2 additions & 15 deletions perf/macro/flatMap/perf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,8 @@ var numIterations = iterationInput.valueAsNumber || 1000;
var RxNextFlatMap = document.querySelector('#rx-3-flatmap');
var Rx2FlatMap = document.querySelector('#rx-2-flatmap');

var RxNextTestObservable = new RxNext.Observable(function(observer) {
var index = -1;
while(++index < numIterations) {
observer.next(index);
}
observer.complete();
});

var Rx2TestObservable = Rx.Observable.create(function(observer) {
var index = -1;
while(++index < numIterations) {
observer.onNext(index);
}
observer.onCompleted();
});
var RxNextTestObservable = RxNext.Observable.range(0, numIterations);
var Rx2TestObservable = Rx.Observable.range(0, numIterations);

RxNextFlatMap.addEventListener('click', function() {
RxNextTestObservable.flatMap(projectionRxNext).subscribe();
Expand Down
18 changes: 5 additions & 13 deletions perf/macro/merge/perf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,16 @@ var numIterations = iterationInput.valueAsNumber || 1000;
var Rx2Merge = document.querySelector('#rx-2-merge');
var RxNextMerge = document.querySelector('#rx-3-merge');

var Rx2TestObservable = Rx.Observable.create(generator);
var RxNextTestObservable = new RxNext.Observable(generator);
var Rx2TestObservable = Rx.Observable.range(0, numIterations);
var RxNextTestObservable = RxNext.Observablerange(0, numIterations);

var Rx2TestArgObservable = Rx.Observable.create(generator);
var RxNextTestArgObservable = new RxNext.Observable(generator);
var Rx2TestArgObservable = Rx.Observable.range(0, numIterations);
var RxNextTestArgObservable = RxNext.Observable.range(0, numIterations);

Rx2Merge.addEventListener('click', function() {
Rx2TestObservable.merge(Rx2TestArgObservable).subscribe();
});

RxNextMerge.addEventListener('click', function() {
RxNextTestObservable.merge(RxNextTestArgObservable).subscribe();
});

function generator(observer) {
var index = -1;
while(++index < numIterations) {
observer.onNext(index);
}
observer.onCompleted();
}
});
18 changes: 5 additions & 13 deletions perf/macro/zip/perf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,16 @@ var numIterations = iterationInput.valueAsNumber || 1000;
var Rx2Zip = document.querySelector('#rx-2-zip');
var RxNextZip = document.querySelector('#rx-3-zip');

var Rx2TestObservable = Rx.Observable.create(generator);
var RxNextTestObservable = new RxNext.Observable(generator);
var Rx2TestObservable = Rx.Observable.range(0, numIterations);
var RxNextTestObservable = RxNext.Observable.range(0, numIterations);

var Rx2TestArgObservable = Rx.Observable.create(generator);
var RxNextTestArgObservable = new RxNext.Observable(generator);
var Rx2TestArgObservable = Rx.Observable.range(0, numIterations);
var RxNextTestArgObservable = RxNext.Observable.range(0, numIterations);

Rx2Zip.addEventListener('click', function() {
Rx2TestObservable.zip(Rx2TestArgObservable).subscribe();
});

RxNextZip.addEventListener('click', function() {
RxNextTestObservable.zip(RxNextTestArgObservable).subscribe();
});

function generator(observer) {
var index = -1;
while(++index < numIterations) {
observer.onNext(index);
}
observer.onCompleted();
}
});

0 comments on commit ca42a32

Please sign in to comment.