Extending settings

JavaScript performance comparison

Test case created by Marcin

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
      
<script>
Benchmark.prototype.setup = function() {
  var objSettings = {
    version: 1
  };
  var objColumn = {
    type: 'text',
    fillHandle: true,
    source: ["A", "B"]
  }
  
  function Settings() {}
  Settings.prototype.version = 1;
  
  function Column0() {}
  Column0.prototype = new Settings();
  Column0.prototype.type = 'text';
  Column0.prototype.fillHandle = true;
  Column0.prototype.source = ["A", "B"];

};

Benchmark.prototype.teardown = function() {
  objSettings.version = 1;
  Settings.prototype.version = 1; //simulate updateSettings()

};
</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
Current way
objSettings.version = 2; //simulate updateSettings()
//
var cell = $.extend(true, {}, objSettings, objColumn, {
  fillHandle: false //simulate cells()
});
//
//check if it worked
if (cell.fillHandle !== false) throw new Error('fillHandle');
if (cell.type !== 'text') throw new Error('type');
if (cell.version !== 2) throw new Error('version');
pending…
Proposed way
Settings.prototype.version = 2; //simulate updateSettings()
//
var cell = new Column0();
cell.fillHandle = false; //simulate cells()
//
//check if it worked
if (cell.fillHandle !== false) throw new Error('fillHandle');
if (cell.type !== 'text') throw new Error('type');
if (cell.version !== 2) throw new Error('version');
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