Skip to content

Instantly share code, notes, and snippets.

@tomlagier
Created July 3, 2017 06:15
Show Gist options
  • Save tomlagier/549c1e49074551d715d8549feb42b6e9 to your computer and use it in GitHub Desktop.
Save tomlagier/549c1e49074551d715d8549feb42b6e9 to your computer and use it in GitHub Desktop.
let root, nodes, layout, i;
for (i = 0; i < 10; i++) {
console.time('D3');
root = d3.hierarchy({children: children.map(node=>node.toSmall())})
.sum(node => node.value);
layout = d3.pack()
.size([d.width, d.width])
.padding(1.5);
nodes = layout(root).leaves()
nodes.forEach(node => delete node.parent);
console.timeEnd('D3');
}
for (i = 0; i < 10; i++) {
console.time('WASM');
root = new Module.Hierarchy({
size: [d.width, d.width],
padding: 1.5
}, { value: 0, children: children.map(node => node.toSmall())});
nodes = root.pack().leaves();
console.timeEnd('WASM');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment