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
Original discussion at http://stackoverflow.com/questions/1232040/how-to-empty-an-array-in-javascript.
var small = [],
medium = [],
big = [],
smallSize = 100,
mediumSize = 10000,
bigSize = 100000;
while (smallSize--) {
small.push(Math.random());
}
while (mediumSize--) {
medium.push(Math.random());
}
while (bigSize--) {
big.push(Math.random());
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Overwriting with a new array (small) |
| ready |
Overwriting with a new array (medium) |
| ready |
Overwriting with a new array (big) |
| ready |
Setting length to 0 (small) |
| ready |
Setting length to 0 (medium) |
| ready |
Setting length to 0 (big) |
| ready |
Using splice (small) |
| ready |
Using splice (medium) |
| ready |
Using splice (big) |
| ready |
Using while, pop (small) |
| ready |
Using while, pop (medium) |
| ready |
Using while, pop (big) |
| ready |
Using while, unshift (small) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.