jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
This is a simple rendering speed test between the most popular libraries/frameworks. I added in Mithril because it's a newcomer with some promise.
<!-- Jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.1.0/knockout-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.5.1/ember.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mithril/0.1.12/mithril.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/0.10.4/vue.min.js"></script>
<script src="http://canjs.com/release/2.2.7/can.jquery.js">
</script>
<script src="http://underscorejs.org/underscore-min.js"></script>
<script src="http://backbonejs.org/backbone-min.js"></script>
<!-- Angular -->
<div ng-app>
Angular:
<span ng-controller="Ctrl" id="angList"><span ng-repeat="item in data">{{item}}</span></span>
</div>
<!-- canJS -->
<div id="canapp">
<h3>Can</h3>
</div>
<script type="text/ejs" id="canEJS">
<% items.each(function(item) { %>
<span><%= item %></span>
<% } ) %>
</script>
<div id="backboneapp">
<h3>Backbone</h3>
<span class="backbone-items"></span>
</div>
<!-- React -->
<div id="react">
React: <span id="reactMountNode"></span>
</div>
<!-- Mithril -->
<div id="mithrilapp">
Mithril: <span id="mithrilMountNode"></span>
</div>
<script>
var Ctrl = function($scope){ $scope.data = []; };
var KOData = ko.observableArray();
var KOviewmodel = {data: KOData};
var ENV = {EXTEND_PROTOTYPES: false};
var ReactComponent = React.createClass({displayName: 'PerfTest',
getInitialState: function() {
return { data: [] };
},
render: function() {
return (
React.DOM.span(null,
this.state.data.map(function(result) {
return React.DOM.span( {key:result.id}, result.text);
})
)
);
}
});
var MithrilData = new Array();
var mithapp = {
controller: function() {
this.data = MithrilData;
},
view: function(ctrl) {
return m("span", [ctrl.data.map(function(datum) { return m('span', datum); })]);
}
}
$(document).ready(function() {
angular.element(document).ready(function() {
var ang_scope = $('#angList').scope();
window.ANGclear = function(){
ang_scope.data = [];
ang_scope.$apply();
};
window.ANGpush = function(data){
ang_scope.data.push(data);
ang_scope.$apply();
};
});
ko.applyBindings(KOviewmodel, document.getElementById('koapp'));
window.KOclear = function (){
KOData.splice(0, KOData().length);
};
window.KOpush = function (data){
KOData.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});
}
m.module(document.getElementById("mithrilMountNode"), mithapp);
window.Mclear = function() {
m.startComputation();
MithrilData.splice(0);
m.endComputation();
};
window.Mpush = function(data) {
m.startComputation();
MithrilData.push(data);
m.endComputation();
}
//CanJS
var can_items = new can.Observe.List([]);
$('#canapp')
.append(can.view('canEJS', {
items: can_items
}));
window.CAN = {
clear: function() {
can_items.splice(0);
},
push: function(item) {
can_items.push(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"});
});
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Angular 10 |
| ready |
Angular 100 |
| ready |
React 10 |
| ready |
React 100 |
| ready |
Mithril 10 |
| ready |
Mithril 100 |
| ready |
canJS 10 |
| ready |
canJS 100 |
| ready |
Backbone 10 |
| ready |
Backbone 100 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.