Angular VS Knockout VS Ember VS React VS Mithril VS Mercury VS Reactive

JavaScript performance comparison

Revision 836 of this test case created by test

Preparation code

<!-- Jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<!-- Angular -->
<div ng-app>
    Angular:
    <span ng-controller="Ctrl" id="angList"><span ng-repeat="item in data">{{item}}</span></span>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.16/angular.min.js"></script>

<script>
    var Ctrl = function($scope) {
        $scope.data = [];
    };

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

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

</script>



<!-- Knockout -->
<div id="koapp">
    Knockout:
    <span data-bind="foreach: data"><span data-bind="text: $data"></span></span>
</div>

<script src="https://cdn.jsdelivr.net/knockout/3.2.0/knockout.js"></script>

<script>
    var KOData = ko.observableArray();
    var KOviewmodel = {data: KOData};

    ko.applyBindings(KOviewmodelRL, document.getElementById('koappRL'));
    window.KOclearRL = function (){
        KODataRL.splice(0, KOData().length);
    };
    window.KOpushRL = function (data){
        KODataRL.push(data);
    };
</script>


<!-- Ember -->

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

<script>
    var ENV = {EXTEND_PROTOTYPES: false};
</script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.6.1/ember.min.js"></script>

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

    window.EMclear = function () {
        EMapp.data.clear();
    };
    window.EMpush = function (data) {
        EMapp.data.pushObject(data);
    };
</script>

<!--Backbone-->
<script src="http://underscorejs.org/underscore-min.js"></script>
<script src="http://backbonejs.org/backbone-min.js"></script>

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

<script>
    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"});
</script>


<div id="backboneappv2">
    Backbone Without Jquery (perf x 2)
    <span class="backbone-items"></span>
</div>

<script>
    var backboneViewV2 = Backbone.View.extend({
        clearV2: function() {
            this.el.innerHTML = "";
        },
        pushV2: function(i) {
            this.el.innerHTML+=i;
        },
    });
    window.BB2 = new backboneViewV2({el: "#backboneappv2 .backbone-items"});
</script>

    

Preparation code output

<!-- Jquery --> <!-- Angular --> <div ng-app> Angular: <span ng-controller="Ctrl" id="angList"><span ng-repeat="item in data">{{item}}</span></span> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.16/angular.min.js"></script> <script> var Ctrl = function($scope) { $scope.data = []; }; angular.element(document).ready(function() { var ang_scope = $('#angList').scope(); window.ANGclear = function() { ang_scope.data.splice(0, ang_scope.data.length); ang_scope.$digest(); }; window.ANGpush = function(data) { ang_scope.data.push(data + ang_scope.data.length); ang_scope.$digest(); }; }); </script> <!-- Knockout --> <div id="koapp"> Knockout: <span data-bind="foreach: data"><span data-bind="text: $data"></span></span> </div> <script src="https://cdn.jsdelivr.net/knockout/3.2.0/knockout.js"></script> <script> var KOData = ko.observableArray(); var KOviewmodel = {data: KOData}; ko.applyBindings(KOviewmodelRL, document.getElementById('koappRL')); window.KOclearRL = function (){ KODataRL.splice(0, KOData().length); }; window.KOpushRL = function (data){ KODataRL.push(data); }; </script> <!-- Ember --> <div id="emapp"> <script type="text/x-handlebars"> Ember: <span> {{#each EMapp.data}}<span>{{this}}</span>{{/each}} </span> </script> </div> <script> var ENV = {EXTEND_PROTOTYPES: false}; </script> <script src="https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.6.1/ember.min.js"></script> <script> EMapp = Ember.Application.create({ rootElement: '#emapp' }); EMapp.data = Ember.A(); window.EMclear = function () { EMapp.data.clear(); }; window.EMpush = function (data) { EMapp.data.pushObject(data); }; </script> <!--Backbone--> <script src="http://underscorejs.org/underscore-min.js"></script> <script src="http://backbonejs.org/backbone-min.js"></script> <div id="backboneapp"> Backbone <span class="backbone-items"></span> </div> <script> 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"}); </script> <div id="backboneappv2"> Backbone Without Jquery (perf x 2) <span class="backbone-items"></span> </div> <script> var backboneViewV2 = Backbone.View.extend({ clearV2: function() { this.el.innerHTML = ""; }, pushV2: function(i) { this.el.innerHTML+=i; }, }); window.BB2 = new backboneViewV2({el: "#backboneappv2 .backbone-items"}); </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 < 100; i++)
  ANGpush("nitem");
pending…
Knockout
KOclear();
for (var i = 0; i < 100; i++)
  KOpush("kitem");
pending…
Ember
EMclear();
for (var i = 0; i < 100; i++)
  EMpush("eitem");
pending…
Backbone
BB.clear();
for (var i = 0; i < 100; i++) {
  BB.push("BbItem");
}
pending…
Backbone V2
BB2.clearV2();
for (var i = 0; i < 100; i++) {
  BB2.pushV2("Bb2Item");
}
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}}
Knockout:
Backbone
Backbone Without Jquery (perf x 2)