array-proto-mod

JavaScript performance comparison

Test case created by alxhub

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  class MyArray extends Array {}
  
  var count = 0;
  
  var plain = [];
  var direct = new MyArray();
  var augmented = [];
  for (var i = 0; i < 100; i++) {
    plain[i] = Math.random();
    direct[i] = Math.random();
    augmented[i] = Math.random();
  }
  
  Object.setPrototypeOf(augmented, MyArray.prototype);

};

Benchmark.prototype.teardown = function() {
  count = 0;

};
</script>

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
plain
for (var i = 0; i < plain.length; i++) {
  count += plain[i];
}
plain.pop();
plain.push(Math.random());
pending…
direct
for (var i = 0; i < direct.length; i++) {
  count += direct[i];
}
direct.pop();
direct.push(Math.random());
pending…
augmented
for (var i = 0; i < augmented.length; i++) {
  count += augmented[i];
}
augmented.pop();
augmented.push(Math.random());
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