array splice vs. array length = 0

JavaScript performance comparison

Revision 2 of this test case created by Juve

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="txt"></div>
      
<script>
Benchmark.prototype.setup = function() {
  var data = [];
  

};
</script>

Preparation code output

<div id="txt"></div>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
array.splice(10)
data = [1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5]
data.splice(10)
pending…
array.length = 10
data = [1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5]
data.length = 10
pending…
array.splice(0)
data = [1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5]
data.splice(0)
pending…
array.length = 0
data = [1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5]
data.length = 0
pending…

Compare results of other browsers

Revisions

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

0 Comments