Angular VS Knockout VS Ember VS React VS Mithril VS Mercury VS Ractive

JavaScript performance comparison

Revision 599 of this test case created by

Preparation code

<!-- Mercury -->
<script src = "//rawgit.com/Raynos/mercury/master/dist/mercury.js"></script>
    <!-- Jquery -->
    <script src = "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <script src = "//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-rc.5/angular.min.js"></script><script src = "//cdn.jsdelivr.net/knockout/3.2.0/knockout.js"></script><script src = "//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.min.js" ></script><script src = "//cdnjs.cloudflare.com/ajax/libs/ember.js/1.6.1/ember.min.js" ></script><script src = "//cdnjs.cloudflare.com/ajax/libs/react/0.11.2/react.min.js"></script><script src = "//cdnjs.cloudflare.com/ajax/libs/mithril/0.1.34/mithril.min.js"></script><script src = "//cdnjs.cloudflare.com/ajax/libs/vue/0.10.5/vue.min.js" ></script><script src = "//cdnjs.cloudflare.com/ajax/libs/maquette/1.6.0/maquette.min.js"></script><script src = "//helidium.net/Mitol/src/js/lib/bobril/bobril.js" ></script>
    <!-- Angular -->
    <div ng-app = "ngApp">
    Angular 1.3(using track by $index):
    <span ng-controller="Ctrl" id="angList"><span ng-repeat="item in data track by $index" >{{item}}</span></span>
    </div>

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

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

<!-- Ember -->

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

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


<!-- Mithril -->
<div id = "mithrilapp">
    Mithril: <span id="mithrilMountNode"></span></div>


<!-- Vuejs -->
<div id = "vuejs">
    Vuejs: <span id="vuejsMountNode" > <span v-repeat="item: data">{{item}}</span></span>
    </div>

<!-- Mercuryjs -->
<div id = "mercuryjs">
    Mercuryjs: <span id = "mercuryjsMountNode"></span></div>

<!-- Maquette -->
<div id = "maquette">
    Maquette: <span id = "maquetteMountNode"></span></div>

<!-- Bobril -->
<div id = "bobril">
    Bobril: <span id = "bobrilMountNode"></span></div>

<script >
    var timeout = 0;
var ngApp = angular.module('ngApp', []);
ngApp.controller('Ctrl', function($scope) {
    $scope.data = [];
});
var KOData = ko.observableArray();
var KOviewmodel = {
    data: KOData
};

var ENV = {
    EXTEND_PROTOTYPES: false
};

var ReactData = [];
var ReactUpdate = null;
var ReactComponent = React.createClass({
    displayName: 'PerfTest',
    getInitialState: function() {
        return {
            data: ReactData
        };
    },
    componentDidMount: function() {
        ReactUpdate = this._onData;
    },
    render: function() {
        return (
            React.DOM.span(null,
                this.state.data.map(function(result) {
                    return React.DOM.span(null, result);
                })
            )
        );
    },
    _onData: function() {
        this.setState({
            data: ReactData
        });
    }
});

var MithrilData = [];
var mithapp = {
    controller: function() {},
    view: function(ctrl) {
        return m("span", [MithrilData.map(function(datum) {
            return m('span', datum);
        })]);
    }
}

var h = mercury.h
var mdata = mercury.array([])

function mrender(data) {
    return h("span", data.map(function(datum) {
        return h('span', datum)
    }));
}

mercury.app(document.getElementById('mercuryjsMountNode'), mdata, mrender)
window.mercuryClear = function() {
    mdata.splice(0, mdata.getLength())
}

window.mercuryPush = function(data) {
    mdata.push(data)
}

var MaquetteData = [];
window.MaquetteClear = function() {
    MaquetteData = [];
};

var BData = [];
window.BobrilClear = function() {
    BData = [];
};

$(document).ready(function() {
    angular.element(document).ready(function() {

        var ang_scope = $('#angList').scope();

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

        };
        window.ANGpush = function(data) {
            ang_scope.data.push(data);
            ang_scope.$digest();
        };
    });

    ko.applyBindings(KOviewmodel, document.getElementById('koapp'));
    window.KOclear = function() {
        KOData.splice(0, KOData().length);
    };
    window.KOpush = function(data) {
        KOData.push(data);
    };


    var KODataRL = ko.observableArray();
    KODataRL.extend({
        rateLimit: 0
    });
    var KOviewmodelRL = {
        data: KODataRL
    };

    ko.applyBindings(KOviewmodelRL, document.getElementById('koappRL'));
    window.KOclearRL = function() {
        KODataRL.splice(0, KOData().length);
    };
    window.KOpushRL = function(data) {
        KODataRL.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, document.getElementById('reactMountNode'));

    window.RClear = function() {
        ReactData.splice(0, ReactData.length);
        ReactUpdate();
    };

    window.RPush = function(data) {
        ReactData.push(data);
        ReactUpdate();
    }

    m.module(document.getElementById("mithrilMountNode"), mithapp);
    window.Mclear = function() {
        MithrilData = [];
    };

    window.Mpush = function(data) {
        MithrilData.push(data);
        m.startComputation();
        m.endComputation();

    }


    var vueInstance = new Vue({
        el: '#vuejsMountNode',
        data: {
            data: []
        }
    });

    window.VueClear = function() {
        vueInstance.data = []
    };

    window.VuePush = function(data) {
        vueInstance.data.push(data);
    };

    var MaquetteComponent = new(function() {
        window.MaquetteProjector = maquette.createProjector(document.getElementById('maquetteMountNode'), function() {
            var i = 0;
            return maquette.h('span', {
                key: 'holder'
            }, MaquetteData.map(function(datum) {
                return maquette.h('span.child' + (i++), {}, [datum]);
            }));
        }, {});
    })();
    window.MaquettePush = function(data) {
        MaquetteData.push(data);
        MaquetteProjector.scheduleRender();


    };

var BobrilModule = {
init: function( ctx, node ) { },
render: function( ctx, node ) {
b.assign(node, {tag:'span', children:[ctx.data.text]});
},
destroy: function( ctx, node ) {}
};

    var BobrilComponent = new function() {

        b.init(
            function() {
                return {
                    tag: 'span',
                    children: BData.map(function(datum) {
                        return {
                            component: BobrilModule, data: {text:datum}
                        }
                    })
                };
            },
            document.getElementById('bobrilMountNode')
        );

    };
    window.BobrilPush = function(data) {
        BData.push(data);
        b.invalidate();
    };
});

</script>
    

Preparation code output

<!-- Mercury --> <!-- Jquery --> <script src = "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <script src = "//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-rc.5/angular.min.js"></script><script src = "//cdn.jsdelivr.net/knockout/3.2.0/knockout.js"></script><script src = "//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.3.0/handlebars.min.js" ></script><script src = "//cdnjs.cloudflare.com/ajax/libs/ember.js/1.6.1/ember.min.js" ></script><script src = "//cdnjs.cloudflare.com/ajax/libs/react/0.11.2/react.min.js"></script><script src = "//cdnjs.cloudflare.com/ajax/libs/mithril/0.1.34/mithril.min.js"></script><script src = "//cdnjs.cloudflare.com/ajax/libs/vue/0.10.5/vue.min.js" ></script><script src = "//cdnjs.cloudflare.com/ajax/libs/maquette/1.6.0/maquette.min.js"></script><script src = "//helidium.net/Mitol/src/js/lib/bobril/bobril.js" ></script> <!-- Angular --> <div ng-app = "ngApp"> Angular 1.3(using track by $index): <span ng-controller="Ctrl" id="angList"><span ng-repeat="item in data track by $index" >{{item}}</span></span> </div> <!-- Knockout --> <div id="koapp"> Knockout: <span data-bind="foreach: data"><span data-bind="text: $data"></span></span> </div> <div id = "koappRL"> Knockout: <span data-bind = "foreach: data"> <span data-bind = "text: $data"></span></span> </div> <!-- Ember --> <div id = "emapp"> <script type = "text/x-handlebars"> Ember: <span>{{#each EMapp.data}}<span> {{this}}</span>{{/each}}</span></script></div> <!-- React --> <div id = "react"> React: <span id="reactMountNode"></span></div> <!-- Mithril --> <div id = "mithrilapp"> Mithril: <span id="mithrilMountNode"></span></div> <!-- Vuejs --> <div id = "vuejs"> Vuejs: <span id="vuejsMountNode" > <span v-repeat="item: data">{{item}}</span></span> </div> <!-- Mercuryjs --> <div id = "mercuryjs"> Mercuryjs: <span id = "mercuryjsMountNode"></span></div> <!-- Maquette --> <div id = "maquette"> Maquette: <span id = "maquetteMountNode"></span></div> <!-- Bobril --> <div id = "bobril"> Bobril: <span id = "bobrilMountNode"></span></div> <script > var timeout = 0; var ngApp = angular.module('ngApp', []); ngApp.controller('Ctrl', function($scope) { $scope.data = []; }); var KOData = ko.observableArray(); var KOviewmodel = { data: KOData }; var ENV = { EXTEND_PROTOTYPES: false }; var ReactData = []; var ReactUpdate = null; var ReactComponent = React.createClass({ displayName: 'PerfTest', getInitialState: function() { return { data: ReactData }; }, componentDidMount: function() { ReactUpdate = this._onData; }, render: function() { return ( React.DOM.span(null, this.state.data.map(function(result) { return React.DOM.span(null, result); }) ) ); }, _onData: function() { this.setState({ data: ReactData }); } }); var MithrilData = []; var mithapp = { controller: function() {}, view: function(ctrl) { return m("span", [MithrilData.map(function(datum) { return m('span', datum); })]); } } var h = mercury.h var mdata = mercury.array([]) function mrender(data) { return h("span", data.map(function(datum) { return h('span', datum) })); } mercury.app(document.getElementById('mercuryjsMountNode'), mdata, mrender) window.mercuryClear = function() { mdata.splice(0, mdata.getLength()) } window.mercuryPush = function(data) { mdata.push(data) } var MaquetteData = []; window.MaquetteClear = function() { MaquetteData = []; }; var BData = []; window.BobrilClear = function() { BData = []; }; $(document).ready(function() { angular.element(document).ready(function() { var ang_scope = $('#angList').scope(); window.ANGclear = function() { ang_scope.data = []; }; window.ANGpush = function(data) { ang_scope.data.push(data); ang_scope.$digest(); }; }); ko.applyBindings(KOviewmodel, document.getElementById('koapp')); window.KOclear = function() { KOData.splice(0, KOData().length); }; window.KOpush = function(data) { KOData.push(data); }; var KODataRL = ko.observableArray(); KODataRL.extend({ rateLimit: 0 }); var KOviewmodelRL = { data: KODataRL }; ko.applyBindings(KOviewmodelRL, document.getElementById('koappRL')); window.KOclearRL = function() { KODataRL.splice(0, KOData().length); }; window.KOpushRL = function(data) { KODataRL.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, document.getElementById('reactMountNode')); window.RClear = function() { ReactData.splice(0, ReactData.length); ReactUpdate(); }; window.RPush = function(data) { ReactData.push(data); ReactUpdate(); } m.module(document.getElementById("mithrilMountNode"), mithapp); window.Mclear = function() { MithrilData = []; }; window.Mpush = function(data) { MithrilData.push(data); m.startComputation(); m.endComputation(); } var vueInstance = new Vue({ el: '#vuejsMountNode', data: { data: [] } }); window.VueClear = function() { vueInstance.data = [] }; window.VuePush = function(data) { vueInstance.data.push(data); }; var MaquetteComponent = new(function() { window.MaquetteProjector = maquette.createProjector(document.getElementById('maquetteMountNode'), function() { var i = 0; return maquette.h('span', { key: 'holder' }, MaquetteData.map(function(datum) { return maquette.h('span.child' + (i++), {}, [datum]); })); }, {}); })(); window.MaquettePush = function(data) { MaquetteData.push(data); MaquetteProjector.scheduleRender(); }; var BobrilModule = { init: function( ctx, node ) { }, render: function( ctx, node ) { b.assign(node, {tag:'span', children:[ctx.data.text]}); }, destroy: function( ctx, node ) {} }; var BobrilComponent = new function() { b.init( function() { return { tag: 'span', children: BData.map(function(datum) { return { component: BobrilModule, data: {text:datum} } }) }; }, document.getElementById('bobrilMountNode') ); }; window.BobrilPush = function(data) { BData.push(data); b.invalidate(); }; }); </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
Bobril
BobrilClear();
for (var i = 0; i < 100; i++)
  BobrilPush("bitem" + Date.now());
pending…
Maquette
MaquetteClear();
for (var i = 0; i < 100; i++)
  MaquettePush("maitem" + Date.now());
pending…
React
RClear();

for (var i = 0; i < 100; i++)
  RPush("ritem" + Date.now());
pending…
Angular
ANGclear();

for (var i = 0; i < 100; i++)
  ANGpush("nitem" + Date.now());
pending…
vuejs
VueClear();
for (var i = 0; i < 100; i++)
  VuePush("vitem" + Date.now());
pending…
Ember
EMclear();
for (var i = 0; i < 100; i++)
  EMpush("eitem" + Date.now());
pending…
Mercury
mercuryClear();
for (var i = 0; i < 100; i++)
  mercuryPush("mitem" + Date.now());
pending…
Mithril
Mclear();
for (var i = 0; i < 100; i++)
  Mpush("mitem" + Date.now());
pending…
Knockout
KOclear();
for (var i = 0; i < 100; i++)
  KOpush("kitem" + Date.now());
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 1.3(using track by $index): {{item}}
Knockout:
Knockout:
React:
Mithril:
Vuejs: {{item}}
Mercuryjs:
Maquette:
Bobril: