apply vs for loop as for String.fromCharCode

JavaScript performance comparison

Test case created by a_bicky

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var array = [];
  for (var i = 0; i < 1000; i++) {
    array[i] = i;
  }

};
</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
String.fromCharCode.apply
var str = String.fromCharCode(null, array);
pending…
String.fromCharCode using for loop
var str = "";
for (var i = 0, len = array.length; i < len; i++) {
  str += String.fromCharCode(array[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.

0 Comments