forked from w8r/graphology-layout-forceatlas2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbench.js
38 lines (34 loc) · 844 Bytes
/
bench.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* eslint no-console: 0 */
/**
* Graphology FA2 Layout Bench
* ============================
*
* Simplistic benchmark to assess some performance improvements.
*/
var Graph = require('graphology'),
layout = require('./index.js'),
randomClusters = require('graphology-generators/random/clusters'),
seedrandom = require('seedrandom');
var rng = function() {
return seedrandom('bench');
};
console.time('Creation');
var graph = randomClusters(Graph, {
order: 5000,
size: 100000,
clusters: 5,
rng: rng()
});
graph.nodes().forEach(function(node) {
graph.setNodeAttribute(node, 'x', Math.random());
graph.setNodeAttribute(node, 'y', Math.random());
});
console.timeEnd('Creation');
console.time('Layout');
layout(graph, {
settings: {
barnesHutOptimize: true
},
iterations: 50
});
console.timeEnd('Layout');