Skip to content

Instantly share code, notes, and snippets.

@stianl
Last active September 8, 2016 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stianl/07b1817e58651587dc11a60317b558e8 to your computer and use it in GitHub Desktop.
Save stianl/07b1817e58651587dc11a60317b558e8 to your computer and use it in GitHub Desktop.
OQL javascript code to count packages with most class definitions
// Count packages with most class definitions (excluding class definitions in java.lang.*)
var set = {};
top(map(unique(map(filter(heap.classes(), function(it) {
return !it.name.substr(0,it.name.lastIndexOf('.')).startsWith('java.lang');
}), function(it) {
var pName = it.name.substr(0,it.name.lastIndexOf('.'));
if (set[pName]) {
set[pName]++;
} else {
set[pName] = 1;
}
return pName;
})), function(it) {
return {name: it, classDefinitionCount: set[it]}
}), 'rhs.classDefinitionCount - lhs.classDefinitionCount');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment