Script Preparation code:
AخA
 
function randomCharCodes(n) {
  const arr = new Uint8Array(n);
  for(let i=0;i<n;i++) {
    arr[i] = ~~(Math.random()*0x100)
  }
  return arr;
}
const chars1 = randomCharCodes(1024*1024);
var chars = chars1;
function test1(arr) {
  const l = arr.length;
  var i = 0;
  var s = "";
  for(;i<l;i++){
    s+=String.fromCharCode(arr[i]);
  }
  return s;
}
function test2(arr) {
  return String.fromCharCode.apply(null, arr);
}
function test3(arr) {
  const l = arr.length;
  var i = 0;
  var a = [];
  for(;i<l;i++){
    a[i]=String.fromCharCode(arr[i]);
  }
  return a.join("");
}
Tests:
  • For-loop

     
    var t1 = test1(chars);
  • String.fromCharCode.apply

     
    var t2 = test2(chars);
  • join method

     
    var t3 = test3(chars);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    For-loop
    String.fromCharCode.apply
    join method

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36
Chrome 81 on Mac OS X 10.14.6
View result in a separate tab
Test name Executions per second
For-loop 4.3 Ops/sec
String.fromCharCode.apply 0.0 Ops/sec
join method 5.3 Ops/sec