console.log performance

JavaScript performance comparison

Revision 2 of this test case created by

Preparation code

<div id="container"></div>
      
<script>
Benchmark.prototype.setup = function() {
  var container = document.getElementById("container");
  
  function doSomethingAndWriteToLog() {
    for(var i = 0 ; i < 1000 ; i++) {
      var div = document.createElement("DIV");
      var span = document.createElement("SPAN");
      div.appendChild(span);
      container.appendChild(div);
      console.log(i);
    }
  }
  
  function justDoSomething() {
    for(var i = 0 ; i < 1000 ; i++) {
      var div = document.createElement("DIV");
      var span = document.createElement("SPAN");
      div.appendChild(span);
      container.appendChild(div);
    }
  }
  
  function doSomethingAndLogWhenDone(){
    for(var i = 0 ; i < 1000 ; i++) {
      var div = document.createElement("DIV");
      var span = document.createElement("SPAN");
      div.appendChild(span);
      container.appendChild(div);
    }
    console.log("Completed DOM operations!");
  }

};

Benchmark.prototype.teardown = function() {
  container.innerHTML = "";

};
</script>

Preparation code output

<div id="container"></div>

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
iterations with logging
doSomethingAndWriteToLog();
pending…
iterations without logging
justDoSomething();
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