.map vs. for

Benchmark created by Andreas Göbel on


Preparation HTML

<script>
  var demo = "2px 2px 10px rgb(68, 187, 117)";
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
map
var stripped = demo.split(/rgb\(/)[1].split(',').map(function(value) {
 return parseInt(value, 10).toString(16);
});
ready
for
var res = demo.split(/rgb\(/)[1].split(',');
for (var i = 0, len = res.length; i < len; i++) {
 res[i] = parseInt(res[i], 10).toString(16);
}
ready

Revisions

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

  • Revision 1: published by Andreas Göbel on