-
-
Save mranney/2ec5deab2c59fe16b306 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require("fs"), obj, con_nodes = {}, con_counts = {}; | |
obj = JSON.parse(fs.readFileSync("heap.json")); | |
Object.keys(obj.children).forEach(function (key1) { | |
var l1 = obj.children[key1]; | |
Object.keys(l1).forEach(function (key2) { | |
var l2 = l1[key2], cn = l2.constructorName; | |
if (typeof l2.constructorName === "string") { | |
if (con_nodes[cn] === undefined) { | |
con_nodes[cn] = 0; | |
con_counts[cn] = 0; | |
} | |
con_nodes[cn]++; | |
if (typeof l2.count === "number") { | |
con_counts[cn] += l2.count; | |
} | |
} else { | |
console.log("No constructor name: ", l2); | |
} | |
}); | |
}); | |
console.log("total nodes:\n" + Object.keys(con_nodes).sort(function (a, b) { | |
return con_nodes[a] > con_nodes[b]; | |
}).slice(-10).map(function (val) { | |
return val + ": " + con_nodes[val] + "\n"; | |
}).join("")); | |
console.log("sum of counts:\n" + Object.keys(con_counts).sort(function (a, b) { | |
return con_counts[a] > con_counts[b]; | |
}).slice(-10).map(function (val) { | |
return val + ": " + con_counts[val] + "\n"; | |
}).join("")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
total nodes: | |
(context): 9 | |
number: 21 | |
system / Map: 66 | |
system / JSGlobalPropertyCell: 114 | |
prod-nr146.voxer.com: 129 | |
: 302 | |
Object: 396 | |
Connection: 870 | |
TCP: 3308 | |
HTTPParser: 10443 | |
sum of counts: | |
indexOf: 51370 | |
(object elements): 87378 | |
Timer: 89834 | |
SlowBuffer: 108144 | |
number: 244481 | |
: 2707876 | |
Object: 3235524 | |
Connection: 7671436 | |
TCP: 27211696 | |
HTTPParser: 89591724 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
total nodes: | |
Array: 5 | |
system / FunctionTemplateInfo: 16 | |
number: 21 | |
system / Map: 66 | |
prod-nr146.voxer.com: 100 | |
system / JSGlobalPropertyCell: 114 | |
: 302 | |
Object: 949 | |
TCP: 3526 | |
HTTPParser: 14787 | |
sum of counts: | |
Pipe: 88433 | |
lastIndexOf: 65845 | |
indexOf: 66178 | |
(object elements): 112058 | |
Timer: 143768 | |
prod-nr146.voxer.com: 977070 | |
: 3467650 | |
Connection: 9098179 | |
TCP: 33525412 | |
HTTPParser: 166933009 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment