Decode ASCII string from ArrayBuffer

JavaScript performance comparison

Test case created by Joshua Bell

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var octets = (function() {
      var a = [];
      for (var i = 0x20; i < 0x7F; ++i) {
        a.push(i);
      }
      return a;
    }());
    var buffer = new Uint8Array(octets);
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
concatenation
var result = '';
for (var i = 0; i < buffer.length; ++i) {
  result += String.fromCharCode(buffer[i]);
}
pending…
map
var result = Array.prototype.map.call(buffer, String.fromCharCode).join('');
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment