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
<script src="http://cdn.jsdelivr.net/jquery/1.11.2/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/knockout/3.3.0/knockout-min.js"></script>
<script src="http://builds.emberjs.com/canary/ember-template-compiler.js"></script>
<script src="http://builds.emberjs.com/canary/ember.prod.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/react/0.13.2/react-with-addons.min.js"></script>
<script src="https://cdn.rawgit.com/lhorie/mithril.js/next/mithril.min.js"></script>
<!-- NomJS 0.0.13 -->
<script>!function(e,n,t,r){"use strict";function i(){return null}function o(e){e&&e.render&&"value"in e&&"oninput"in e&&(g.node!==e?(g.node=e,g.value=e.value):g.value!==e.value&&(g.value=e.value,e.oninput()))}function l(n,r,i){var m,g,b,C,N,A,T,x=r,E=[];if(null==n)return n;if((t?n instanceof s:n.nodeType>0)&&!n.render&&(n.render=function(){var e=n.firstChild;for(i||l(n,x);e;)(y?typeof e.render===h:u.call(e.render)===d)&&e.render(),e=e.nextSibling}),(y?typeof r===h:u.call(r)===d)?r=r.bind(n)():"string"==typeof r&&123===r.charCodeAt(0)&&(r=JSON.parse(r)),"object"!=typeof r)return n;f.isArray(r)&&(r={children:r});for(g in r)if(r.hasOwnProperty(g))if(b=r[g],!v||"oninput"!==g||"oninput"in n)if("children"===g&&n.childNodes){for(N=!0,A=0,T=f.isArray(b)?c.apply([],b):[b],C=n.firstChild;C;){if(N===!0)for(;(N=T[A++])&&"string"!=typeof N&&!(t?N instanceof s:N.nodeType>0););"string"==typeof N?(3===C.nodeType?(C.nodeValue!==N&&(C.nodeValue=N),C=C.nextSibling):n.insertBefore(p.createTextNode(N),C),N=!0):(y?typeof C.render===h:u.call(C.render)===d)?N?(C!==N?n.insertBefore(N,C):C=C.nextSibling,N=!0):(E.push(C),C=C.nextSibling):C=C.nextSibling}for(;E.length;)n.removeChild(E.pop());for(var S=T.length-A>0?p.createDocumentFragment():n;T.length>=A;)S.appendChild("string"==typeof N?p.createTextNode(N):(t?N instanceof s:N.nodeType>0)?N:a.els(N)),N=T[A++];S!==n&&S.childNodes.length&&n.appendChild(S)}else if(y?typeof n[g]===h:u.call(n[g])===d);else if("object"==typeof b){if(null!=n[g])for(m in b)b.hasOwnProperty(m)&&n[g][m]!==b[m]&&(n[g][m]=b[m])}else n[g]!==b&&(n[g]=b);else n.onpropertychange=function(){"value"===e.event.propertyName&&o(n)};return n}var a={el:i,els:i,mount:i,supported:n&&r,version:"0.0.13"};if(n)var f=e.Array,p=e.document,c=f.prototype.concat,s=e.Node,d="[object Function]",u=Object.prototype.toString,h="function",y=typeof i===h&&typeof/./!==h,m=p.createElement("div"),g={},v="all"in p&&!e.atob;n&&"attachEvent"in p&&v&&p.attachEvent("onselectionchange",function(){o(p.activeElement)}),n&&(a.el=function(e,n,t){var r,i=0;if(y?typeof n!==h:u.call(n)!==d)switch(null==n&&(n={}),null==t&&(t=!0),typeof n){case"object":f.isArray(n)&&(n={children:n});break;case"boolean":case"number":n=n.toString();default:n={children:n}}if("string"==typeof e)for(r=e.match(/([#.]?[^#.]+)/g),e=p.createElement(r[0]);++i<r.length;)switch(r[i].charCodeAt(0)){case 35:e.id=r[i].slice(1);break;case 46:e.className=r[i].slice(1)}return l(e,n,!!t)},a.els=function(e){var n,r,i=p.createDocumentFragment(),o=0;for(e=c.apply([],arguments);e.length>o;)if(n=e[o++],t?n instanceof s:n.nodeType>0)i.appendChild(n);else if("string"==typeof n)for(m.innerHTML=n;m.firstChild;)i.appendChild(m.firstChild);else if(f.isArray(n))i.appendChild(nomElements.apply(this,n));else if("object"==typeof n)for(r in n)n.hasOwnProperty(r)&&i.appendChild(a.el(r,n[r]));return i},a.mount=function(e){function n(){for(var e,t=o.length;t;)e=o[--t],e.parentElement?(y?typeof e.parentElement.render!==h:u.call(e.parentElement.render)!==d)&&e.render():o.splice(t,1);o.length&&r&&requestAnimationFrame(n)}var i,o=[],l=[],f=0;for((t?e instanceof s&&11===e.nodeType:11===e.nodeType)||(e=a.els.apply(this,arguments));e.childNodes.length>f;)l.push(i=e.childNodes[f++]),(y?typeof i.render===h:u.call(i.render)===d)&&o.push(i);return e.unmount=function(){for(o.length=0;l.length;)e.appendChild(l.shift());return e},r&&requestAnimationFrame(n),e}),"object"==typeof exports?module.exports=a:typeof define===h&&define.amd?define(function(){return a}):e.nom=a}(this,"document"in this,"Node"in this,"requestAnimationFrame"in this);</script>
<!-- Angular -->
<div ng-app="jsperf">
Angular:
<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>
<!-- Ember -->
<div id="emapp"></div>
<script type="text/x-handlebars">
Ember:
<span>
{{#each EMapp.data}}<span>{{this}}</span>{{/each}}
</span>
</script>
<!-- React -->
<div id="react">
React: <span id="reactMountNode"></span>
</div>
<!-- Mithril -->
<div id="mithrilapp">
Mithril: <span id="mithrilMountNode"></span>
</div>
<!-- NomJS -->
<div id="nomapp">
NomJS: <span id="nomMountNode"></span>
</div>
<script>
var r = function() {
return '' + (Date.now() % 10);
};
var Ctrl = function($scope) {
$scope.data = [];
};
angular.module('jsperf', [])
.controller('Ctrl', Ctrl);
var KOData = ko.observableArray();
var KOviewmodel = {
data: KOData
};
var ENV = {
EXTEND_PROTOTYPES: false
};
var MithrilData = [];
var mithapp = {
controller: function() {
this.data = MithrilData;
},
view: function(ctrl) {
return m("span", ctrl.data.map(function(datum) {
return m('span', datum);
}));
}
};
var NomData = [];
var NomElCache = [];
var NomApp = nom.el('span', function() {
return NomData.map(function(data, index) {
if (!NomElCache[index]) {
NomElCache[index] = nom.el('span', function() {
return { children: NomData[index] };
});
}
return NomElCache[index];
});
});
$(document).ready(function() {
angular.element(document).ready(function() {
var ang_scope = $('#angList').scope();
window.ANGclear = function() {
ang_scope.data = [];
ang_scope.$digest();
};
window.ANGpush = function(data) {
ang_scope.data.push(data);
ang_scope.$digest();
};
});
ko.applyBindings(KOviewmodel, document.getElementById('koapp'));
window.KOclear = function() {
KOData.removeAll();
};
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);
};
document.getElementById('nomMountNode').appendChild(nom.mount(NomApp));
window.Nclear = function() {
NomData.length = 0;
}
window.Npush = function(data) {
NomData.push(data);
}
m.module(document.getElementById("mithrilMountNode"), mithapp);
window.Mclear = function() {
m.startComputation();
MithrilData.length = 0;
m.endComputation();
};
window.Mpush = function(data) {
m.startComputation();
MithrilData.push(data);
m.endComputation();
};
var PerfTest = React.createClass({
displayName: 'PerfTest',
getInitialState: function() {
return { data: [] };
},
render: function() {
return React.createElement('span', null, this.state.data.map(function(data,i) {
return React.createElement('span', {key: i}, data);
}));
}
});
var reactComp = React.render(React.createElement(PerfTest, null), document.getElementById('reactMountNode'));
window.RClear = function() {
reactComp.setState({
data: []
});
};
window.RPush = function(data) {
reactComp.state.data.push(data);
reactComp.forceUpdate();
};
});
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Mithril |
| ready |
React |
| ready |
Angular |
| ready |
Knockout |
| ready |
Ember |
| ready |
NomJS |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.