__proto__OR_slice

JavaScript performance comparison

Test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  function makeArraySlice(object) {
    return slice.call(object);
  }
  
  function makeArrayProto(object) {
    object.__proto__ = ArrayPrototype;
    return object;
  }
  
  Object.setPrototypeOf || (Object.setPrototypeOf = function (o, p) {
    o.__proto__ = p;
    return o;
  });
  
  var ArrayPrototype = Array.prototype,
      slice = ArrayPrototype.slice,
      setPrototypeOf = Object.setPrototypeOf,
      result;

};
</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
slice
for (var i = 0, o; i < 0xFF; i++) {
  o = {};
  o.length = i;
  result = makeArraySlice(o);
}
pending…
__proto__
for (var i = 0, o; i < 0xFF; i++) {
  o = {};
  o.length = i;
  result = makeArrayProto(o);
}
pending…
Object.setPrototypeOf
for (var i = 0, o; i < 0xFF; i++) {
  o = {};
  o.length = i;
  result = setPrototypeOf(o, ArrayPrototype);
}
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