Array cmp vs string cmp

JavaScript performance comparison

Test case created by chris

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var array1 = ['one', 'two', 'three', 'four', 'five'];
    var array2 = ['one', 'two', 'three', 'four', 'five'];
};
</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
string
(function() {
  return array1.join('/') == array2.join('/');
})();
pending…
array
(function() {
  var len1 = array1.length;

  if(len1 != array2.length) {
    return false;
  }

  for(var i = 0; i < len1; i++) {
    if(array1[i] != array2[i]) {
      return false;
    }
  }
  return true;
})();
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