Skip to content

Instantly share code, notes, and snippets.

@Satyam
Created September 2, 2012 08:20
Show Gist options
  • Save Satyam/3595837 to your computer and use it in GitHub Desktop.
Save Satyam/3595837 to your computer and use it in GitHub Desktop.
TreeView Speed test
YUI(
{gallery: 'gallery-2012.08.29-20-10'}
).use('gallery-yui3treeview-ng', function (Y) {
'use strict';
var count = 0,
makeBranch = function (prefix, depth) {
var branch = [], node;
count +=1;
for (var i = 0; i < 5; i+=1) {
node = {label: prefix + '-' + i, collapsed: !!(i % 2)};
if (depth < 3) {
node.children = makeBranch(prefix + '-' + i, depth + 1);
}
branch.push(node);
}
return branch;
},
tree = {
startCollapsed: false,
children: makeBranch('label',0)
};
console.log('node count:', count);
window.setTimeout( function () {
console.time('TreeView');
var tv = new Y.TreeView(tree);
tv.render('#container');
console.timeEnd('TreeView');
},10);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment