Editing YUI TreeView shootout This edit will create a new revision. Your details (optional) Name Email (won’t be displayed; might be used for Gravatar) URL Test case details Title * Published (uncheck if you want to fiddle around before making the page public) Description (in case you feel further explanation is needed)(Markdown syntax is allowed) Comparing the init/render performance of various YUI TreeView implementations. Are you a spammer? (just answer the question) Preparation code Preparation code HTML (this will be inserted in the <body> of a valid HTML5 document in standards mode) (useful when testing DOM operations or including libraries) <div id="treeview"></div> <script src="http://yui.yahooapis.com/3.8.0/build/yui/yui-min.js"></script> <script src="http://smugmug.github.com/yui-gallery/build/gallery-sm-tree/gallery-sm-tree-min.js"></script> <script src="http://smugmug.github.com/yui-gallery/build/gallery-sm-tree-node/gallery-sm-tree-node-min.js"></script> <script src="http://smugmug.github.com/yui-gallery/build/gallery-sm-treeview/gallery-sm-treeview-min.js"></script> <script src="http://smugmug.github.com/yui-gallery/build/gallery-sm-treeview-templates/gallery-sm-treeview-templates-min.js"></script> <script> var Y = YUI({fetchCSS: false}).use('gallery-sm-treeview', 'gallery-fwt-treeview'); // Separate YUI instances needed to avoid class name collisions. var Y2 = YUI({fetchCSS: false}).use('gallery-yui3treeview'); var Y3 = YUI({fetchCSS: false}).use('gallery-yui3treeview-ng'); </script> Include JavaScript libraries as follows: <script src="//cdn.ext/library.js"></script> Define setup for all tests (variables, functions, arrays or other objects that will be used in the tests) (runs before each clocked test loop, outside of the timed code region) (e.g. define local test variables, reset global variables, clear canvas, etc.) (see FAQ) var container = document.getElementById('treeview'); // Generate a bunch of bogus data to fill the tree with. var nodes = [], typeNodes = [], // gallery-yui3treeview needs an extra "type" property on parent nodes, and this breaks gallery-fwt-treeview child, end, node, typeNode, start; for (var i = 0; i < 20; i++) { node = {label: 'Item ' + i}; typeNode = {label: 'Item ' + i}; // Fill every third node with 20 children. if (i % 3 === 0) { fillChildren(node, 20); fillChildren(typeNode, 20, null, true); } // Fill every tenth node with children to a depth of 50. if (i % 10 === 0) { fillChildren(node, 1, 50); fillChildren(typeNode, 1, 50, true); } nodes.push(node); typeNodes.push(typeNode); } function fillChildren(parent, count, depth, includeType) { var child; if (!parent.children) { if (includeType) { parent.type = 'TreeView'; } parent.children = []; } for (var i = 0; i < count; i++) { child = {label: 'Child ' + i}; if (depth) { fillChildren(child, count, depth - 1); } parent.children.push(child); } } Define teardown for all tests (runs after each clocked test loop, outside of the timed code region) (see FAQ) document.getElementById('treeview').innerHTML = ''; Code snippets to compare Test 1 Title Async (check if this is an asynchronous test) Code new Y.TreeView({ container: container, nodes : nodes }).render(); Test 2 Title Async (check if this is an asynchronous test) Code new Y.FWTreeView({tree: nodes}).render(container); Test 3 Title Async (check if this is an asynchronous test) Code new Y2.TreeView({children: typeNodes}).render(container); Test 4 Title Async (check if this is an asynchronous test) Code new Y3.TreeView({children: nodes}).render(container);