First x elements: slice vs length (v12)

Revision 12 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
bigArray.slice(0, 100);
ready
Length
bigArray.length = 100;
ready

Revisions

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