String.fromCharCode Test

JavaScript performance comparison

Revision 16 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var chars = [];
  for (var i = 0, l = 65535; i < l; i++) {
      chars.push(Math.round(Math.random() * 255))
  }

};
</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
Using a loop
var s = "";
for(var i=0,l=chars.length; i<l; i++)
    s += String.fromCharCode(chars[i]);
pending…
Using apply
var s = String.fromCharCode.apply(null, chars);
pending…
Apply with window
var s = String.fromCharCode.apply(window, chars);
pending…
Apply with String
var s = String.fromCharCode.apply(String, chars);
pending…
Using another loop
var a = [];
for(var i=0,l=chars.length; i<l; i++)
    a.push(String.fromCharCode(chars[i]));
var s = a.join();
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