Prototype lookup

JavaScript performance comparison

Revision 3 of this test case created

Info

Benchmarks performance of a lookup through several levels of prototype inheritance.

Preparation code

<script>
  function ctor() {}

  function inherit(obj) {
    ctor.prototype = obj;
    return new ctor();
  }

  var l0 = {
    "run": function() {
      return;
    }
  };
  var l1 = inherit(l0);
  var l2 = inherit(l1);
  var l3 = inherit(l2);
  var l4 = inherit(l3);
  var l5 = inherit(l4);
  var l6 = inherit(l5);
  var l7 = inherit(l6);

  function loop(obj) {
    obj.run();
  }
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
0 levels
loop(l0);
pending…
1 level
loop(l1);
pending…
2 levels
loop(l2);
pending…
3 levels
loop(l3);
pending…
4 levels
loop(l4);
pending…
5 levels
loop(l5);
pending…
6 levels
loop(l6);
pending…
7 levels
loop(l7);
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. Here’s a list of current revisions for this page:

0 comments

Add a comment