I want to profile an observableArray
in KnockoutJS to see how long it's taking to fill and render the observableArray
in HTML.
I planned to use an old school method like below. Is the results I'll get from this be accurate? Or is there a better way to do this profiling
JavaScript
var arr = [],
itemCount = 200;
for (var i = 0; i < itemCount; i++) {
arr.push('item ' + i);
}
var t1 = new Date();
var viewModel = {
items: ko.observableArray(arr),
vmName: ko.observable('View Model')
};
ko.applyBindings(viewModel);
var t2 = new Date();
console.log(t2 - t1); //Shows the time in milliseconds
HTML
<div data-bind="foreach: items">
<div data-bind="html: $data"></div>
</div>
Graph I generated from the results