Backbone vs Angular vs Ember

JavaScript performance comparison

Test case created

Preparation code

<script src="//code.jquery.com/jquery-1.9.1.min.js">
</script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.3/angular.min.js">
</script>
<script src="//rawgithub.com/wycats/handlebars.js/1.0.0-rc.3/dist/handlebars.js"></script>
<script src="//rawgithub.com/emberjs/ember.js/release-builds/ember-1.0.0-rc.2.js">
</script>
<script src="//underscorejs.org/underscore.js"></script>
<script src="//backbonejs.org/backbone.js"></script>

<!-- Ember -->
<div id="emapp">
        <h3>Ember</h3>
  <script type="text/x-handlebars">
    <span>{{#each EMAPP.items}}<span>{{this}}</span>{{/each}}</span>
  </script>
</div>

<!-- Angular -->
<div ng-app="ANGAPP" id="angapp" ng-controller="Ctrl">
        <h3>Angular</h3>
        <span ng-repeat="item in items">{{item}}</span>
</div>

<!-- Backbone -->
<div id="backboneapp">
  <h3>Backbone</h3>
  <span class="backbone-items"></span>
</div>

<script>
// Angular
angular.module('ANGAPP', [])
        .controller('Ctrl', function($scope) {
        $scope.items = [];
         window.ANG = {
            clear: function() {
                $scope.items.splice(0);
              $scope.$digest();
            },
            push: function(item) {
              $scope.items.push(item);
              $scope.$digest();
        }
        };
        });

//Ember
window.EMAPP = Ember.Application.create({
  rootElement: $('#emapp')
});
EMAPP.items = Ember.A();

window.EM = {
  clear: function() {
    EMAPP.items.clear();
  },
  push: function(item) {
    EMAPP.items.pushObject(item);
  }
}

// Backbone.js

var backboneView = Backbone.View.extend({
  push: function(i) {
    this.$el.append(i);
  },
  clear: function() {
    this.$el.html('');
  }

});

window.BB = new backboneView({el: "#backboneapp .backbone-items"});

console.log(window.BB);
</script>
 

Preparation code output

Ember

Angular

{{item}}

Backbone

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Backbone
BB.clear();
for(var i = 0; i < 50; i++) {
  BB.push(i);
}
pending…
Angular
ANG.clear();
for(var i = 0; i < 50; i++) {
  ANG.push(i);
}
pending…
Ember
EM.clear();
for(var i = 0; i < 50; i++) {
  EM.push(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. Here’s a list of current revisions for this page:

0 comments

Add a comment