bind vs unshift

Benchmark created by hiasltiasl on


Setup

var arrProto = Array.prototype;
    var arr = [];
    
    function uPushXAnd() {
      arrProto.unshift.call(arguments, "x");
      arrProto.push.apply(arr, arguments);
    }
    
    function bPushXAnd() {
      arrProto.push.bind(arr, "x").apply(this, arguments);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
bind 1
bPushXAnd(1)
ready
unshift 1
uPushXAnd(1)
ready
bind 1 to 10
bPushXAnd(1,2,3,4,5,6,7,8,9,10)
ready
unshift 1 to 10
uPushXAnd(1,2,3,4,5,6,7,8,9,10)
ready

Revisions

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

  • Revision 1: published by hiasltiasl on