forEach-for-Ext.each with break

Benchmark created by Nisheeth on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/ext-core/3/ext-core.js">
</script>

Setup

var string1 = 'aasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdaadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewezxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjikhgfdsadzxcbvnbmhjjaasdasdasdasdaqweewewtrdtghjik1';
    
    var array1 = string1.split("");
    var target = [];
    var callback = function(item, index, array) {
        this.push(index);
        if (item == "1") {
          return false;
        }
        return true;
        }
        
        
        
        
        
        
        
    var Arrays = {
    
      forEach: (function() {
        if (Array.prototype.every) {
          return function(array, fn, scope) {
            array.every(fn, scope);
          };
        } else {
          return function(array, fn, scope) {
            array = array || [];
            var len = array.length >>> 0;
            var i = 0;
            if (len) {
              do {
                if (!fn.call(scope || array[i], array[i], i++, array)) {
                  return false;
                };
              } while (--len)
            }
          };
        }
      }()),
    
      bitwiseLoop: function(array, fn, scope) {
        array = array || [];
        var length = array.length;
        var mod = length & 3;
        var times = length >> 2;
        var i = 0;
    
        if (times) {
          do {
            if (!fn.call(scope || array[i], array[i], i++, array)) {
              return false;
            };
            if (!fn.call(scope || array[i], array[i], i++, array)) {
              return false;
            };
    
            if (!fn.call(scope || array[i], array[i], i++, array)) {
              return false;
            };
    
            if (!fn.call(scope || array[i], array[i], i++, array)) {
              return false;
            };
    
          } while (--times);
        }
        while (mod--) {
          if (!fn.call(scope || array[i], array[i], i++, array)) {
            return false;
          };
    
        }
      }
    }

Teardown


    target = [];
  

Test runner

Ready to run.

Testing in
TestOps/sec
forEach
Arrays.forEach(array1, callback, target);
ready
Arrays.bitwiseLoop
Arrays.bitwiseLoop(array1, callback, target);
ready
Ext.each
Ext.each(array1, callback, target);
ready
For
for (var i = 0, ii = array1.length; i < ii; i++) {
  if (!callback.call(target, array1[i], i, array1)) {
    break;
  };
}
ready

Revisions

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

  • Revision 1: published by Nisheeth on