tKO 4.0.0-alpha3 Perf Test
HTML
<script src="https://rawgit.com/brianmhunt/tko-alpha-pub/master/ko.js"></script>
<div id='x'>
<strong>{{ count }} / {{ time }} ms</strong>
<custom-component></custom-component>
</div>
<div id='cc-template'>
cc
{{# unless: finished }}
<custom-component></custom-component>
{{ /unless }}
</div>
JavaScript
let count = ko.observable(0)
let time = ko.observable(false)
const start = performance.now()
const ITERATIONS = 1000
const viewModel = function () {
vm = {};
vm.finished = count() > ITERATIONS;
count(count() + 1);
time(performance.now() - start);
vm.amazingFunction = function () {
// do things
};
return vm;
};
ko.components.register("custom-component", {
viewModel, template: {element: 'cc-template'}
})
ko.applyBindings({count, time}, document.getElementById('x'))