Angular VS Ember VS React

JavaScript performance comparison

Revision 785 of this test case created by

Preparation code

<!-- Jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/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.min.js"></script>

<!-- Angular -->
<div ng-app>
  Angular:
  <span ng-init="data = []" 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>

//var Ctrl = function($scope){
//    $scope.data = [];
//};

var ENV = {EXTEND_PROTOTYPES: false};

var ReactComponent = React.createClass({displayName: 'PerfTest',
  getInitialState: function() {
    return { data: [] };
  },
  render: function() {
    var res = [];
    for(var i = 0; i < this.state.data.length; i++) {
      res.push(React.DOM.span({ key: 'test' + i }, this.state.data[i]));
    }
    return React.DOM.span(null, res);
  }
});


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

    window.ANGclear = function(){
      ang_scope.data = [];
    };
    window.ANGpush = function(data){
      ang_scope.data.push(data);
    };
  });


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

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


  var reactComp = ReactComponent();
  React.renderComponent(reactComp, $('#reactMountNode')[0]);

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

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

});

</script>
    

Preparation code output

<!-- Jquery --> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/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.min.js"></script> <!-- Angular --> <div ng-app> Angular: <span ng-init="data = []" 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> //var Ctrl = function($scope){ // $scope.data = []; //}; var ENV = {EXTEND_PROTOTYPES: false}; var ReactComponent = React.createClass({displayName: 'PerfTest', getInitialState: function() { return { data: [] }; }, render: function() { var res = []; for(var i = 0; i < this.state.data.length; i++) { res.push(React.DOM.span({ key: 'test' + i }, this.state.data[i])); } return React.DOM.span(null, res); } }); $(document).ready(function() { angular.element(document).ready(function() { var ang_scope = angular.element('#angList').scope(); window.ANGclear = function(){ ang_scope.data = []; }; window.ANGpush = function(data){ ang_scope.data.push(data); }; }); EMapp = Ember.Application.create({ rootElement: '#emapp' }); EMapp.data = Ember.A(); window.EMclear = function () { EMapp.data.clear(); }; window.EMpush = function (data) { EMapp.data.pushObject(data); }; var reactComp = ReactComponent(); React.renderComponent(reactComp, $('#reactMountNode')[0]); window.RClear = function() { reactComp.setState({data: []}) }; window.RPush = function(data) { var stateData = reactComp.state.data; stateData.push(data); 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 1000
ANGclear();
for (var i = 0; i < 1000; i++)
  ANGpush("ngitem"+i);
pending…
Ember 1000
EMclear();
for (var i = 0; i < 1000; i++)
  EMpush("emitem"+i);
pending…
React 1000
RClear();
for (var i = 0; i < 1000; i++)
  RPush("ritem"+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: