push/pop vs unshift/shift (v11)

Revision 11 of this benchmark created on


Preparation HTML

<script>
  var pl = ['a', 'b', 'c', 'd'];
  var sl = ['b', 'c', 'd', 'e'];
  
  var e, a, v;
</script>
      

      
        
  };


      
</script>

Setup

Benchmark.prototype.setup = function() {

            <script>
  pl.unshift(e)
  pl.pop()

Test runner

Ready to run.

Testing in
TestOps/sec
Push/Pop
pl.push('e');
e = pl.pop();
ready
Unshift/Shift
sl.unshift('a');
a = sl.shift();
ready
Push/Access/Pop
pl.push('e');
v = pl[4];
e = pl.pop();
ready
Unshift/Access/Shift
sl.unshift('a');
v = sl[0];
a = sl.shift();
ready

Revisions

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