Angular VS Ember VS React

JavaScript performance comparison

Revision 786 of this test case created by Lance

Preparation code

<!-- Jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.4/ember-template-compiler.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.4/ember.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script>

<!-- Angular -->
<div ng-app="app" ng-jq>
  Angular:
<span ng-controller="Ctrl" id="angList"><span ng-repeat="item in data track by item">{{::item}}</span></span>
</div>

<!-- Ember -->

<div id="emapp"></div>
<script type="text/x-handlebars">
  Ember:
  <span>
    {{#each EMapp.data}}<span>{{this}}</span>{{/each}}
  </span>
</script>


<!-- React -->
<div id="react">
  React: <span id="reactMountNode"></span>
</div>

<script>
window.getId = function(idx)
  {
    var d = Date.now() + "";
    return idx + "-" + d.substring(d.length - 6);
  };

angular.module('app', [])
.controller('Ctrl', ['$scope', Ctrl]);
function Ctrl($scope) {
    $scope.data = [];
    $scope.push = function(data) {
        $scope.data.push(data);
    }
};

var ReactComponent = React.createClass({displayName: 'PerfTest',
  getInitialState: function() {
    return { data: [] };
  },
  render: function() {
    return (
       React.createElement("span", null,
        this.state.data.map(function(result) {
console.log(result);
          return React.createElement("span", null, result);
        })
      )
    );
  }
});

$(document).ready(function() {

  EMapp = Ember.Application.create({
    rootElement: '#emapp'
  });
  EMapp.data = Ember.A();

  window.EMclear = function () {
    EMapp.data.clear();
  };
  window.EMpush = function (data) {
    EMapp.data.pushObject(data);
  };


  angular.element(document).ready(function() {
    var ang_scope = angular.element(document.getElementById('angList')).scope();

    window.ANGclear = function(){
      ang_scope.data.length = 0;
      ang_scope.$evalAsync();
    };
    window.ANGpush = function(data){
        ang_scope.push(data);
    };
  });


  var reactComp = React.render( React.createElement(ReactComponent, null), document.getElementById('reactMountNode'));

  window.RClear = function() {
    reactComp.setState({data: []})
  };

  window.RPush = function(entry) {
    var stateData = reactComp.state.data;
    stateData.push(entry);
    reactComp.setState({data: stateData});
  }

});
</script>
    

Preparation code output

<!-- Jquery --> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.4/ember-template-compiler.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.4/ember.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script> <!-- Angular --> <div ng-app="app" ng-jq> Angular: <span ng-controller="Ctrl" id="angList"><span ng-repeat="item in data track by item">{{::item}}</span></span> </div> <!-- Ember --> <div id="emapp"></div> <script type="text/x-handlebars"> Ember: <span> {{#each EMapp.data}}<span>{{this}}</span>{{/each}} </span> </script> <!-- React --> <div id="react"> React: <span id="reactMountNode"></span> </div> <script> window.getId = function(idx) { var d = Date.now() + ""; return idx + "-" + d.substring(d.length - 6); }; angular.module('app', []) .controller('Ctrl', ['$scope', Ctrl]); function Ctrl($scope) { $scope.data = []; $scope.push = function(data) { $scope.data.push(data); } }; var ReactComponent = React.createClass({displayName: 'PerfTest', getInitialState: function() { return { data: [] }; }, render: function() { return ( React.createElement("span", null, this.state.data.map(function(result) { console.log(result); return React.createElement("span", null, result); }) ) ); } }); $(document).ready(function() { EMapp = Ember.Application.create({ rootElement: '#emapp' }); EMapp.data = Ember.A(); window.EMclear = function () { EMapp.data.clear(); }; window.EMpush = function (data) { EMapp.data.pushObject(data); }; angular.element(document).ready(function() { var ang_scope = angular.element(document.getElementById('angList')).scope(); window.ANGclear = function(){ ang_scope.data.length = 0; ang_scope.$evalAsync(); }; window.ANGpush = function(data){ ang_scope.push(data); }; }); var reactComp = React.render( React.createElement(ReactComponent, null), document.getElementById('reactMountNode')); window.RClear = function() { reactComp.setState({data: []}) }; window.RPush = function(entry) { var stateData = reactComp.state.data; stateData.push(entry); reactComp.setState({data: stateData}); } }); </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
Angular
ANGclear();
for (var i = 0; i < 1000; i++) {
  ANGpush("nitem" + getId(i));
}
pending…
Ember
EMclear();
for (var i = 0; i < 1000; i++)
  EMpush("eitem" + getId(i));
pending…
React
RClear();
for (var i = 0; i < 1000; i++)
  RPush("ritem" + getId(i));
pending…

Compare results of other browsers

Revisions

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

0 Comments

Angular: {{::item}}
React: