map

JavaScript performance comparison

Test case created by Nikolay Frantsev

Preparation code

<script>
  var data = "foo, bar, baz & quux!";
</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
map
var binary = Array.prototype.map.call(data, function(byte) {
  return byte.charCodeAt(0) & 255;
});
pending…
for
var binary = [];
for (var i = 0, l = data.length; i < l; i++)
binary.push(data[i].charCodeAt(0) & 255);
pending…
for 2
var binary = [];
for (var i = 0, l = data.length; i < l; i++)
binary.push(data.charCodeAt(i) & 255);
pending…
for 3
var binary = [];
for (var i = 0, l = data.length; i < l; i++)
binary.push(data.charAt(i).charCodeAt(0) & 255);
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. Here’s a list of current revisions for this page:

0 comments

Add a comment