liquidlava-class-system-performance-ff

JavaScript performance comparison

Test case created by Vyacheslav Egorov

Preparation code

<script src="https://dl.dropboxusercontent.com/u/3554716/jsperf/lava-class-manager.js"></script>
<script>
///////////////////////////////////////////////////////////////////
// Create classes via Lava.ClassManager

var window = (function () { return this })();

Lava.ClassManager.registerRootNamespace('window', window);
Lava.ClassManager.define(
'window.LavaParentClass',
{
    counter: 0,
    method: function() { this.counter++; }
});

Lava.ClassManager.define(
'window.LavaChildClass',
{
    Extends: 'window.LavaParentClass',
    method: function() { this.LavaParentClass$method(); }
});

function loop(o, flag) {
  for (var i = 0; i < 20000; i++) {
    o.method();
  }

  if (flag) {  // Prevent inlining by inflating method body
    for (var i = 0; i < 1; i++) {
      o.method();
    }
    for (var i = 0; i < 1; i++) {
      o.method();
    }
    for (var i = 0; i < 1; i++) {
      o.method();
    }
    for (var i = 0; i < 1; i++) {
      o.method();
    }
    for (var i = 0; i < 1; i++) {
      o.method();
    }
    for (var i = 0; i < 1; i++) {
      o.method();
    }
    for (var i = 0; i < 1; i++) {
      o.method();
    }
    for (var i = 0; i < 1; i++) {
      o.method();
    }
  }
}

// Need this to get fast LavaInstance on FF.
for (var i = 0; i < 10; i++) {
  var LavaInstance1 = new LavaChildClass();
  LavaInstance1.method();
}

loop(LavaInstance1);  // Warm up loop.
</script>
      
<script>
Benchmark.prototype.setup = function() {
  var LavaInstance2 = new LavaChildClass();
  

};
</script>

Preparation code output

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
Same
loop(LavaInstance1)
pending…
Diff
loop(LavaInstance2)
pending…
Same (2)
// If run after Diff then at this point loop is recompiled
// to use [get|set]propcache instead of 
// [get|set]fixedslot for accessing the x.
loop(LavaInstance1)
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