-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(test): add macro performance tests for zip
- Loading branch information
Showing
3 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>RxJS 3 Perf Tests</title> | ||
<script src="../../../dist/global/Rx.js"></script> | ||
<script type="text/javascript"> | ||
window.RxNext = window.Rx; | ||
window.Rx = void 0; | ||
</script> | ||
<script src="../../../node_modules/rx/dist/rx.all.js"></script> | ||
|
||
</head> | ||
<body> | ||
<a href="../">perf index</a> | ||
<label> | ||
Number of Iterations | ||
<input type="number" name="iteration"> | ||
</label> | ||
<button id="rx-2-zip">Rx2 Zip Test</button> | ||
<button id="rx-3-zip">RxNext Zip Test</button> | ||
<script src="perf.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var iterationInput = document.querySelector('input[name=iteration]'); | ||
var match = /iterations=(\w+)/.exec(decodeURIComponent(location.search)); | ||
|
||
if (match) { | ||
iterationInput.value = match[1]; | ||
} | ||
|
||
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 Rx2TestArgObservable = Rx.Observable.create(generator); | ||
var RxNextTestArgObservable = new RxNext.Observable(generator); | ||
|
||
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
var benchpress = require('benchpress'); | ||
var runner = new benchpress.Runner([ | ||
benchpress.SeleniumWebDriverAdapter.PROTRACTOR_BINDINGS, | ||
benchpress.Validator.bindTo(benchpress.RegressionSlopeValidator), | ||
benchpress.bind(benchpress.RegressionSlopeValidator.SAMPLE_SIZE).toValue(20), | ||
benchpress.bind(benchpress.RegressionSlopeValidator.METRIC).toValue('scriptTime'), | ||
benchpress.bind(benchpress.Options.FORCE_GC).toValue(false) | ||
]); | ||
|
||
describe('zip comparison', function () { | ||
[ | ||
1000, | ||
10000 | ||
].forEach(function (val) { | ||
it('should be fast in Rx2', function (done) { | ||
browser.ignoreSynchronization = true; | ||
browser.get('http://localhost:8080/perf/macro/zip/index.html?iterations=' + val); | ||
runner.sample({ | ||
id: 'zip Rx2', | ||
execute: function () { | ||
$('#rx-2-zip').click(); | ||
}, | ||
bindings: [ | ||
benchpress.bind(benchpress.Options.SAMPLE_DESCRIPTION).toValue({ | ||
iterations: val | ||
}) | ||
] | ||
}).then(done, done.fail); | ||
}); | ||
|
||
it('should be fast in RxNext', function (done) { | ||
browser.ignoreSynchronization = true; | ||
browser.get('http://localhost:8080/perf/macro/zip/index.html?iterations=' + val); | ||
runner.sample({ | ||
id: 'zip RxNext', | ||
execute: function () { | ||
$('#rx-3-zip').click(); | ||
}, | ||
bindings: [ | ||
benchpress.bind(benchpress.Options.SAMPLE_DESCRIPTION).toValue({ | ||
iterations: val | ||
}) | ||
] | ||
}).then(done, done.fail); | ||
}); | ||
}); | ||
}); |