jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
We want to find out the differences between two sorted arrays. Eg : [1, 2, 3, 4, 5] and [3, 4, 5] should return [1, 2]
Much larger arrays are used in practice.
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.min.js"></script>
<script src="https://rawgithub.com/lodash/lodash/2.4.1/dist/lodash.min.js"></script>
var foo = [], bar = [], num;
for(var i=0;i<10000;i++) {
num = Math.floor(Math.random() * 1000000);
foo.push(num);
if (Math.random() > 0.5) num = Math.floor(Math.random() * 1000000);
bar.push(num);
}
foo.sort();
bar.sort();
Ready to run.
Test | Ops/sec | |
---|---|---|
Native javascript |
| ready |
jQuery |
| ready |
LoDash |
| ready |
angular |
| ready |
Native JS no function calls |
| ready |
Hash |
| ready |
Sort |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.