CS vs ES6

JavaScript performance comparison

Test case created by Oleg

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  "use strict";
  
  
  var runCS = function() {
    var i, len, ref, s, v;
    s = '';
    ref = ['a', 'b', 'c', 'd', 'e'];
    for (i = 0, len = ref.length; i < len; i++) {
      v = ref[i];
      s += v;
    }
    return null;
  };
  
  var runES6 = function() {
    var s = "";
    var _iteratorNormalCompletion = true;
    var _didIteratorError = false;
    var _iteratorError = undefined;
  
    try {
      for (var _iterator = ["a", "b", "c", "d", "e"][Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
        v = _step.value;
  
        s += v;
      }
    } catch (err) {
      _didIteratorError = true;
      _iteratorError = err;
    } finally {
      try {
        if (!_iteratorNormalCompletion && _iterator["return"]) {
          _iterator["return"]();
        }
      } finally {
        if (_didIteratorError) {
          throw _iteratorError;
        }
      }
    }
  }
  
  var runES6b = function() {
    var s = "";
    for (var _iterator = ["a", "b", "c", "d", "e"], _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
      if (_isArray) {
        if (_i >= _iterator.length) break;
        v = _iterator[_i++];
      } else {
        _i = _iterator.next();
        if (_i.done) break;
        v = _i.value;
      }
  
      s += v;
    }
  }

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
CS
runCS();
pending…
ES6
runES6();
pending…
ES6 Loose mode
runES6b();
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