Last active
September 8, 2016 10:02
-
-
Save stianl/07b1817e58651587dc11a60317b558e8 to your computer and use it in GitHub Desktop.
OQL javascript code to count packages with most class definitions
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
// 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