Proto Lookup

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var charList = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "p"];
   
    var charLen = charList.length;
    var i, j, v;
   
    var o1 = {
      a: 1,
      b: 2
    };
    var o2 = {
      c: 1,
      d: 2
    };
    var o3 = {
      e: 1,
      f: 2
    };
    var o4 = {
      g: 1,
      h: 2
    };
    var o5 = {
      h: 1,
      k: 2
    };
    var o6 = {
      l: 1,
      m: 2
    };
    var o7 = {
      n: 1,
      p: 2
    };
   
    var o = [o1, o2, o3, o4, o5, o6, o7];
   
    var p7 = {
      n: 1,
      p: 2,
    };
    var p6 = {
      __proto__: p7,
      l: 1,
      m: 2
    };
    var p5 = {
      __proto__: p6,
      h: 1,
      k: 2
    };
    var p4 = {
      __proto__: p5,
      g: 1,
      h: 2
    };
    var p3 = {
      __proto__: p4,
      e: 1,
      f: 2
    };
    var p2 = {
      __proto__: p3,
      c: 1,
      d: 2
    };
    var p1 = {
      __proto__: p2,
      a: 1,
      b: 2
    };
};
</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
Loop
for (i = 0; i < charLen; i++) {

  j = 6;
  while (j-- && v == null) {
    v = o[j][charList[i]];
  }

}
pending…
Proto
for (i = 0; i < charLen; i++) {

  v = p1[charList[i]];

}
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