First x elements: slice vs length (v41)

Revision 41 of this benchmark created on


Description

Comparing runtimes of length and slice for decreasing array size.

Setup

var bigArray = [];
    // Large = 100,000
    for (var i = 0; i < 100000; i++) {
      bigArray.push(i % 42);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Slice
var bigArray2 = bigArray.slice(0);
bigArray2.slice(0, 100);
ready
Length
var bigArray2 = bigArray.slice(0);
bigArray2.length = 100;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.