splice and shift

Benchmark created by John-David Dalton on


Description

Test if array.splice(0, 1)[0] is as fast as array.shift()

Setup

var array = ['a', 'b', 'c'],
        altShift = Benchmark.Suite.prototype.shift,
        altSplice = Benchmark.Suite.prototype.splice;

Test runner

Ready to run.

Testing in
TestOps/sec
shift
array.shift();
array = ['a', 'b', 'c'];
ready
splice
array.splice(0, 1)[0];
array = ['a', 'b', 'c'];
ready
alt shift
altShift.call(array);
array = ['a', 'b', 'c'];
ready
alt splice
altSplice.call(array, 0, 1)[0];
array = ['a', 'b', 'c'];
ready

Revisions

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

  • Revision 1: published by John-David Dalton on