fancy_vs_humble

JavaScript performance comparison

Test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  'use strict';
  
  var _reducers_orig;
  
  var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  
  var PUBLICIZE_SHARE = 'PUBLICIZE_SHARE';
  var PUBLICIZE_SHARE_SUCCESS = 'PUBLICIZE_SHARE_SUCCESS';
  var PUBLICIZE_SHARE_FAILURE = 'PUBLICIZE_SHARE_FAILURE';
  var PUBLICIZE_SHARE_DISMISS = 'PUBLICIZE_SHARE_DISMISS';
  
  var reducers_orig = (_reducers_orig = {}, _defineProperty(_reducers_orig, PUBLICIZE_SHARE, function (state, _ref) {
  		var siteId = _ref.siteId,
  		    postId = _ref.postId;
  		return _extends({}, state, _defineProperty({}, siteId, _extends({}, state[siteId], _defineProperty({}, postId, {
  				requesting: true
  		}))));
  }), _defineProperty(_reducers_orig, PUBLICIZE_SHARE_SUCCESS, function (state, _ref2) {
  		var siteId = _ref2.siteId,
  		    postId = _ref2.postId;
  		return _extends({}, state, _defineProperty({}, siteId, _extends({}, state[siteId], _defineProperty({}, postId, {
  				requesting: false,
  				success: true
  		}))));
  }), _defineProperty(_reducers_orig, PUBLICIZE_SHARE_FAILURE, function (state, _ref3) {
  		var siteId = _ref3.siteId,
  		    postId = _ref3.postId,
  		    error = _ref3.error;
  		return _extends({}, state, _defineProperty({}, siteId, _extends({}, state[siteId], _defineProperty({}, postId, {
  				requesting: false,
  				success: false,
  				error: error
  		}))));
  }), _defineProperty(_reducers_orig, PUBLICIZE_SHARE_DISMISS, function (state, _ref4) {
  		var siteId = _ref4.siteId,
  		    postId = _ref4.postId;
  		return _extends({}, state, _defineProperty({}, siteId, _extends({}, state[siteId], _defineProperty({}, postId, undefined))));
  }), _reducers_orig);
  
  var _reducers_mod;
  function update(state, action, post_status) {
    var next_state = Object.assign({}, state);
    var post = {};
    post[action.postId] = post_status;
    next_state[action.siteId] = Object.assign({}, next_state[action.siteId], post);
    return next_state;
  };
  
  var reducers_mod = (_reducers_mod = {}, _defineProperty(_reducers_mod, PUBLICIZE_SHARE, function (state, action) {
    return update(state, action, { requesting: true });
  }), _defineProperty(_reducers_mod, PUBLICIZE_SHARE_SUCCESS, function (state, action) {
    return update(state, action, { requesting: false, success: true });
  }), _defineProperty(_reducers_mod, PUBLICIZE_SHARE_FAILURE, function (state, action) {
    return update(state, action, { requesting: false, success: false, error: action.error });
  }), _defineProperty(_reducers_mod, PUBLICIZE_SHARE_DISMISS, function (state, action) {
    return update(state, action, undefined);
  }), _reducers_mod);

};
</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
Original
var res_orig = reducers_orig[ PUBLICIZE_SHARE ]({}, {siteId:12, postId : 34});
pending…
Modified
var res_mod = reducers_mod[ PUBLICIZE_SHARE ]({}, {siteId:12, postId : 34});
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