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.
This version of the test is much slower because it needs to copy the pre-populated array in each iteration. I have included a control snippet to calculate the time needed for the copy.
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 | |
|---|---|---|
| control (small) | | ready |
| control (medium) | | ready |
| control (big) | | ready |
| new array (small) | | ready |
| new array (medium) | | ready |
| new array (big) | | ready |
| length = 0 (small) | | ready |
| length = 0 (medium) | | ready |
| length = 0 (big) | | ready |
| splice (small) | | ready |
| splice (medium) | | ready |
| splice (big) | | ready |
| while;pop (small) | | ready |
| while;pop (medium) | | ready |
| while;pop (big) | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.