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
Knockout foreach seems slow for large amounts of divs, but how slow?
http://stackoverflow.com/questions/11764755/knockout-js-very-slowly-foreach \n https://github.com/knockout/knockout/issues/248
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/knockout/2.2.1/knockout-min.js"></script>
<table id="myTable" data-bind="foreach: Items">
<tr>
<td data-bind="text: Col1"/>
<td data-bind="text: Col2"/>
<td data-bind="text: Col3"/>
<td data-bind="text: Col4"/>
<td data-bind="text: Col5"/>
<td data-bind="text: Col6"/>
<td data-bind="text: Col7"/>
<td data-bind="text: Col8"/>
<td data-bind="text: Col9"/>
<td data-bind="text: Col10"/>
<td data-bind="text: Col11"/>
<td data-bind="text: Col12"/>
</tr>
</table>
var koModel = function() {
var self = this;
self.Items = ko.observableArray([]);
self.update = function() {
self.Items(mapModel());
};
};
var jqModel = function() {
this.Items = mapModel();
};
function mapModel() {
var arr = [];
console.log('test mapModel start');
for (var t = 0; t < 100; t++) {
arr.push({
Col1: "C1R" + t.toString(),
Col2: "C2R" + t.toString(),
Col3: "C3R" + t.toString(),
Col4: "C4R" + t.toString(),
Col5: "C5R" + t.toString(),
Col6: "C6R" + t.toString(),
Col7: "C7R" + t.toString(),
Col8: "C8R" + t.toString(),
Col9: "C9R" + t.toString(),
Col10: "C10R" + t.toString(),
Col11: "C11R" + t.toString(),
Col12: "C12R" + t.toString()
});
}
console.log(arr);
return arr;
}
var koM = new koModel();
ko.applyBindings(koM);
var viewModel = new jqModel();
Ready to run.
Test | Ops/sec | |
---|---|---|
Knockout |
| ready |
jQuery |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.