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
caching the prototype lookup should be fastest... Would it be even faster if we cache the call too...
<script>
var slice = Array.prototype.slice,
_slice = [].slice,
wslice = window.Array.prototype.slice;
var items = new Array(100);
for (var i = 0; i < 100; i++) {
items[i] = i;
}
function nonnative_slice(obj) {
var items = new Array(obj.length);
for (var i = obj.length; i--; ) {
items[i] = items[i];
}
return items;
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Array.prototype.slice |
| ready |
[].slice |
| ready |
cached prototype |
| ready |
cached [].slice |
| ready |
Array().slice |
| ready |
window.Array |
| ready |
wslice cached |
| ready |
slice(0) |
| ready |
non native slice |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.