Angular VS Ember VS React

JavaScript performance comparison

Revision 673 of this test case created by Matt Richards

Preparation code

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.4/angular.min.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.0.1/ember-template-compiler.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.0.1/ember.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script>


<!-- Angular -->
<script>
var ngApp = angular.module('app',[]);
var Ctrl = function($scope){ $scope.data = []; };
ngApp.controller('Ctrl', Ctrl);
</script>
<div ng-app="app">
  Angular:
  <div ng-controller="Ctrl" id="angList"><ul><li ng-repeat="item in data">{{item}}</ul></div>
</div>

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

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

<script>

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

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

    window.ANGclear = function () {
      ang_scope.$apply(function (scope) {
        scope.data.splice(0, scope.data.length);
      })
    };
    window.ANGpush = function (data){
      ang_scope.$apply(function (scope) {
        scope.data.push(data + scope.data.length);
      })
    };
  });

  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 = React.render( React.createElement(ReactComponent, null), document.getElementById('reactMountNode'));

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

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

}
</script>

    

Preparation code output

<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.0.1/ember-template-compiler.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.0.1/ember.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script> <!-- Angular --> <script> var ngApp = angular.module('app',[]); var Ctrl = function($scope){ $scope.data = []; }; ngApp.controller('Ctrl', Ctrl); </script> <div ng-app="app"> Angular: <div ng-controller="Ctrl" id="angList"><ul><li ng-repeat="item in data">{{item}}</ul></div> </div> <!-- Ember --> <div id="emapp"></div> <script type="text/x-handlebars"> Ember: <ul> {{#each EMapp.data}}<li>{{this}}</li>{{/each}} </ul> </script> <!-- React --> <div id="react"> React: <span id="reactMountNode"></span> </div> <script> var ENV = {EXTEND_PROTOTYPES: false}; var ReactComponent = React.createClass({displayName: 'PerfTest', getInitialState: function() { return { data: [] }; }, render: function() { return ( React.createElement("span", null, this.state.data.map(function(result) { return React.createElement("span", null, result); }) ) ); } }); window.onload = function () { angular.element(document).ready(function () { var ang_scope = angular.element(document.getElementById('angList')).scope(); window.ANGclear = function () { ang_scope.$apply(function (scope) { scope.data.splice(0, scope.data.length); }) }; window.ANGpush = function (data){ ang_scope.$apply(function (scope) { scope.data.push(data + scope.data.length); }) }; }); 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 = React.render( React.createElement(ReactComponent, null), document.getElementById('reactMountNode')); window.RClear = function() { reactComp.setState({data: []}) }; window.RPush = function(data) { var stateData = reactComp.state.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
React
RClear();
for (var i = 0; i < 1000; i++)
  RPush("ritem");
pending…
Angular
ANGclear();
for (var i = 0; i < 1000; i++)
  ANGpush("ngitem")
pending…
Ember
EMclear();
for (var i = 0; i < 1000; i++)
  EMpush("emitem");
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:
React: