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
Testing/profiling the code patterns from the Script Junkie article "(pre)Maturely Optimize Your JavaScript"
http://msdn.microsoft.com/en-us/scriptjunkie/gg622887.aspx
Snippet comparison #2
<script>
function myData_1() {
var idx = 0,
data = [];
this.next = function() {
return data[idx++];
};
this.add = function(val) {
data[data.length] = val;
};
this.size = function() {
return data.length;
};
}
function myData_2() {
var idx = 0,
data = [];
this.size = 0;
this.next = function(num) {
if (num) {
return data.slice(idx, idx += num);
}
return data[idx++];
};
this.add = function(val) {
if (Object.prototype.toString.call(val) == "[object Array]") {
data = data.concat(val);
this.size = data.length;
}
else {
data[data.length] = val;
this.size++;
}
};
}
var obj_1, obj_2, i, tmp_list = [],
tmp_ret;
for (i = 0; i < 1000; i++) {
tmp_list.push(Math.random());
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
iterators |
| ready |
bulk operations |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.