array deconstruction (v2)

Revision 2 of this benchmark created on


Description

Testing Closure Compiler ES5 compiled array deconstruction vs manual assignment.

Setup

var _state = 0;
function useState(initState) {
	return [_state, function(newState) {
		_state = newState;
		return _state;
	}];
}

Test runner

Ready to run.

Testing in
TestOps/sec
ES5 compiled Array deconstruction
function c(a) {
  var b = 0;
  return function() {
    return b < a.length ? {done:!1, value:a[b++]} : {done:!0};
  };
}
function d(a) {
  var b = "undefined" != typeof Symbol && Symbol.iterator && a[Symbol.iterator];
  return b ? b.call(a) : {next:c(a)};
}

var e = d(useState(0)),
state = e.next().value,
setState = e.next().value

setState(state++);
setState(state++);
setState(state++);
ready
Manual assignment
var a = useState(0),
state = a[0],
setState = a[1];

setState(state++);
setState(state++);
setState(state++);
ready

Revisions

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