in application/org.openjdk.jmc.joverflow/src/main/java/org/openjdk/jmc/joverflow/batch/ReportFormatter.java [92:210]
private void formatOverallStats() {
b.println(DASH_SEPARATOR);
b.println("1. OVERALL STATS:\n");
b.println("1.0 Fundamentals\n");
b.format("Pointer size: %d bytes %s\n", hs.ptrSize, hs.usingNarrowPointers ? "(narrow in 64-bit mode)" : "");
b.format("Object header size: %d bytes\n", hs.objHeaderSize);
b.format("Object alignment: %d bytes\n", hs.objAlignment);
b.format("\nTotal num of objects: %,d\n", hs.nObjects);
b.format("Instances: %,d, object arrays: %,d, primitive arrays: %,d\n", hs.nInstances, hs.nObjectArrays,
hs.nValueArrays);
b.format("Total size of all objects: %s\n", b.k(hs.totalObjSize));
b.format("Instances: %s, object arrays: %s, primitive arrays: %s\n", b.k(hs.totalInstSize),
b.k(hs.totalObjArraySize), b.k(hs.totalValueArraySize));
b.print("\nMinimum reported overhead: ");
if (ds.minOvhdToReport < 1024) {
b.println(ds.minOvhdToReport + " bytes");
} else {
b.println((ds.minOvhdToReport / 1024) + "K");
}
b.println("\n1.1 Assorted raw stats; no distinction between collections and standalone arrays\n");
b.format("Total size of object headers: %s\n", b.k(hs.ovhdObjHeaders));
b.format("Num and size of all *$Entry instances: %,d, %s\n", hs.nEntryInstances, b.k(hs.entryClassSize));
ShortArrayStats soa = hs.shortObjArrayStats;
b.format("\nNum and overhead of length 0 obj arrays: %,d %s\n", soa.n0LenObjs, b.k(soa.ovhd0LenObjs));
b.format("Num and overhead of length 1 obj arrays: %,d %s\n", soa.n1LenObjs, b.k(soa.ovhd1LenObjs));
b.format("Num and overhead of length 2..4 obj arrays: %,d %s\n", soa.n4LenObjs, b.k(soa.ovhd4LenObjs));
b.format("Num and overhead of length 5..8 obj arrays: %,d %s\n", soa.n8LenObjs, b.k(soa.ovhd8LenObjs));
ShortArrayStats spa = hs.shortPrimitiveArrayStats;
b.format("\nNum and overhead of length 0 primitive arrays: %,d %s\n", spa.n0LenObjs, b.k(spa.ovhd0LenObjs));
b.format("Num and overhead of length 1 primitive arrays: %,d %s\n", spa.n1LenObjs, b.k(spa.ovhd1LenObjs));
b.format("Num and overhead of length 2..4 primitive arrays: %,d %s\n", spa.n4LenObjs, b.k(spa.ovhd4LenObjs));
b.format("Num and overhead of length 5..8 primitive arrays: %,d %s\n", spa.n8LenObjs, b.k(spa.ovhd8LenObjs));
ShortArrayStats sstrs = hs.shortStringStats;
b.format("\nNum and overhead of length 0 Strings: %,d %s\n", sstrs.n0LenObjs, b.k(sstrs.ovhd0LenObjs));
b.format("Num and overhead of length 1 Strings: %,d %s\n", sstrs.n1LenObjs, b.k(sstrs.ovhd1LenObjs));
b.format("Num and overhead of length 2..4 Strings: %,d %s\n", sstrs.n4LenObjs, b.k(sstrs.ovhd4LenObjs));
b.format("Num and overhead of length 5..8 Strings: %,d %s\n", sstrs.n8LenObjs, b.k(sstrs.ovhd8LenObjs));
NumberEncodingStringStats nesStats = hs.numberEncodingStringStats;
b.format("\nNum and overhead of Strings that encode int numbers: %,d %s\n", nesStats.nStringsEncodingInts,
b.k(nesStats.stringsEncodingIntsOvhd));
b.format("\nNum of boxed Numbers: %,d\n", hs.nBoxedNumbers);
b.format("Overhead of boxed Numbers: %s\n", b.k(hs.ovhdBoxedNumbers));
b.format("\nNum of wrapped Unmodifiable* collection classes:\n");
for (ObjectToIntMap.Entry<String> entry : hs.unmodifiableClasses) {
b.format("%20s : %,d\n", entry.key, entry.value);
}
// FIXME: We probably can't get anything useful out of these collections. Remove calculation of this?
// b.format("\nNum of wrapped Synchronized* collection classes:\n");
// for (ObjectToIntMap.Entry<String> entry : hs.synchronizedClasses) {
// b.format("%20s : %4d\n", entry.key, entry.value);
// }
b.println("\n1.2 Stats on the JVM that produced the dump (from System.getProperties()):\n");
HashMap<String, String> systemProps = hs.systemProperties;
if (systemProps != null) {
for (Map.Entry<String, String> entry : systemProps.entrySet()) {
String key = entry.getKey();
if (key.startsWith("\"java.runtime.") || key.startsWith("\"java.vm.")
|| key.startsWith("\"java.specification.") || key.startsWith("\"os.")) {
b.println(key + " = " + entry.getValue());
}
}
} else {
b.println(" *** Could not be found ***");
}
b.println("\n1.3 Stats on classloaders\n");
ClassloaderStats clStats = hs.classloaderStats;
ObjectToIntMap<JavaObject> clInstToNumLoadedClasses = clStats.getCLInstToNumLoadedClasses();
ObjectToIntMap<JavaClass> clClazzToNumLoadedClasses = clStats.getClClazzToNumLoadedClasses();
int numClTypesWithLoadedClasses = 0;
for (ObjectToIntMap.Entry<JavaClass> entry : clClazzToNumLoadedClasses.getEntries()) {
if (entry.value > 0) {
numClTypesWithLoadedClasses++;
}
}
int numClInstancesWithOneLoaded = 0;
HashSet<JavaClass> clClassesWithOneLoaded = new HashSet<>();
for (ObjectToIntMap.Entry<JavaObject> entry : clInstToNumLoadedClasses.getEntries()) {
if (entry.value == 1) {
numClInstancesWithOneLoaded++;
clClassesWithOneLoaded.add(entry.key.getClazz());
}
}
b.format("Num of classes extending java.lang.ClassLoader: %,d\n", clClazzToNumLoadedClasses.size());
b.format("Classloader instances with loaded classes: num: %,d types: %,d\n", clInstToNumLoadedClasses.size(),
numClTypesWithLoadedClasses);
b.format("Classloader instances with only one loaded class: num: %,d types: %,d\n", numClInstancesWithOneLoaded,
clClassesWithOneLoaded.size());
b.println("\n1.4 Stats on compressible strings\n");
CompressibleStringStats cs = hs.compressibleStringStats;
b.format("Total num of String objects: %,d\n", cs.nTotalStrings);
b.format("Total used bytes in backing arrays: %s\n", b.k(cs.totalUsedBackingArrayBytes));
int percent = (int) (((double) cs.nCompressedStrings) * 100 / cs.nTotalStrings);
b.format("Num of Strings with backing byte[] arrays: %,d (%d%% of all Strings)\n", cs.nCompressedStrings,
percent);
b.format("Total used bytes in backing byte[] arrays: %s\n", b.k(cs.compressedBackingArrayBytes));
percent = (int) (((double) cs.nAsciiCharBackedStrings) * 100 / cs.nTotalStrings);
b.format("Num of Strings backed by ASCII char[] arrays: %,d (%d%% of all Strings)\n",
cs.nAsciiCharBackedStrings, percent);
b.format("Total used bytes in backing ASCII char[] arrays: %s\n", b.k(cs.asciiCharBackingArrayBytes));
}