From ca42a3289d4404caabee22d2037bcad05320d738 Mon Sep 17 00:00:00 2001 From: kwonoj Date: Wed, 9 Sep 2015 13:21:47 -0700 Subject: [PATCH] refactor(test): let macro perf test use range to create observables --- perf/macro/flatMap-scalar/perf.js | 17 ++--------------- perf/macro/flatMap/perf.js | 17 ++--------------- perf/macro/merge/perf.js | 18 +++++------------- perf/macro/zip/perf.js | 18 +++++------------- 4 files changed, 14 insertions(+), 56 deletions(-) diff --git a/perf/macro/flatMap-scalar/perf.js b/perf/macro/flatMap-scalar/perf.js index b005341d5b..5e15937373 100644 --- a/perf/macro/flatMap-scalar/perf.js +++ b/perf/macro/flatMap-scalar/perf.js @@ -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(); diff --git a/perf/macro/flatMap/perf.js b/perf/macro/flatMap/perf.js index 1c3194d5e6..58428e0330 100644 --- a/perf/macro/flatMap/perf.js +++ b/perf/macro/flatMap/perf.js @@ -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(); diff --git a/perf/macro/merge/perf.js b/perf/macro/merge/perf.js index c19b0b7299..ead26358b4 100644 --- a/perf/macro/merge/perf.js +++ b/perf/macro/merge/perf.js @@ -10,11 +10,11 @@ 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(); @@ -22,12 +22,4 @@ Rx2Merge.addEventListener('click', function() { RxNextMerge.addEventListener('click', function() { RxNextTestObservable.merge(RxNextTestArgObservable).subscribe(); -}); - -function generator(observer) { - var index = -1; - while(++index < numIterations) { - observer.onNext(index); - } - observer.onCompleted(); -} +}); \ No newline at end of file diff --git a/perf/macro/zip/perf.js b/perf/macro/zip/perf.js index 3e8ef8fad8..c967aac9b3 100644 --- a/perf/macro/zip/perf.js +++ b/perf/macro/zip/perf.js @@ -10,11 +10,11 @@ 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(); @@ -22,12 +22,4 @@ Rx2Zip.addEventListener('click', function() { RxNextZip.addEventListener('click', function() { RxNextTestObservable.zip(RxNextTestArgObservable).subscribe(); -}); - -function generator(observer) { - var index = -1; - while(++index < numIterations) { - observer.onNext(index); - } - observer.onCompleted(); -} +}); \ No newline at end of file