53 import java.util.Arrays; 54 import java.util.List; 55 56 public class JstatGcCapacityResults extends JstatResults { 57 58 public JstatGcCapacityResults(ToolResults rawResults) { 59 super(rawResults); 60 } 61 62 /** 63 * Checks the overall consistency of the results reported by the tool 64 */ 65 @Override 66 public void assertConsistency() { 67 68 // Check exit code 69 assertThat(getExitCode() == 0, "Unexpected exit code: " + getExitCode()); 70 71 // Check Young Gen consistency 72 float NGCMN = getFloatValue("NGCMN"); 73 float NGCMX = getFloatValue("NGCMX"); 74 assertThat(NGCMX >= NGCMN, "NGCMN > NGCMX (min generation capacity > max generation capacity)"); 75 76 float NGC = getFloatValue("NGC"); 77 assertThat(NGC >= NGCMN, "NGC < NGCMN (generation capacity < min generation capacity)"); 78 assertThat(NGC <= NGCMX, "NGC > NGCMX (generation capacity > max generation capacity)"); 79 80 float S0C = getFloatValue("S0C"); 81 assertThat(S0C <= NGC, "S0C > NGC (survivor space 0 capacity > new generation capacity)"); 82 83 float S1C = getFloatValue("S1C"); 84 assertThat(S1C <= NGC, "S1C > NGC (survivor space 1 capacity > new generation capacity)"); 85 86 float EC = getFloatValue("EC"); 87 assertThat(EC <= NGC, "EC > NGC (eden space capacity > new generation capacity)"); 88 89 // Verify relative size of NGC and S0C + S1C + EC. 90 // The rule depends on if the tenured GC is parallel or not. 91 // For parallell GC: NGC >= S0C + S1C + EC 92 // For non-parallell GC: NGC == S0C + S1C + EC 93 boolean isTenuredParallelGC = isTenuredParallelGC(); 94 String errMsg = String.format( 95 "NGC %s (S0C + S1C + EC) (NGC = %.1f, S0C = %.1f, S1C = %.1f, EC = %.1f, (S0C + S1C + EC) = %.1f)", 96 isTenuredParallelGC ? "<" : "!=", NGC, S0C, S1C, EC, S0C + S1C + EC); 97 if (isTenuredParallelGC) { 98 assertThat(NGC >= S0C + S1C + EC, errMsg); 99 } else { 100 assertThat(checkFloatIsSum(NGC, S0C, S1C, EC), errMsg); 101 } 102 103 // Check Old Gen consistency 104 float OGCMN = getFloatValue("OGCMN"); 105 float OGCMX = getFloatValue("OGCMX"); 106 assertThat(OGCMX >= OGCMN, "OGCMN > OGCMX (min generation capacity > max generation capacity)"); 107 108 float OGC = getFloatValue("OGC"); 109 assertThat(OGC >= OGCMN, "OGC < OGCMN (generation capacity < min generation capacity)"); 110 assertThat(OGC <= OGCMX, "OGC > OGCMX (generation capacity > max generation capacity)"); 111 float OC = getFloatValue("OC"); 112 assertThat(OC == OGC, "OC != OGC (old generation capacity != old space capacity (these values should be equal since old space is made up only from one old generation))"); 113 114 // Check Metaspace consistency 115 float MCMN = getFloatValue("MCMN"); 116 float MCMX = getFloatValue("MCMX"); 117 assertThat(MCMX >= MCMN, "MCMN > MCMX (min generation capacity > max generation capacity)"); 118 float MC = getFloatValue("MC"); 119 assertThat(MC >= MCMN, "MC < MCMN (generation capacity < min generation capacity)"); 120 assertThat(MC <= MCMX, "MGC > MCMX (generation capacity > max generation capacity)"); 121 } 122 123 /** 124 * Check if the tenured generation are currently using a parallel GC. | 53 import java.util.Arrays; 54 import java.util.List; 55 56 public class JstatGcCapacityResults extends JstatResults { 57 58 public JstatGcCapacityResults(ToolResults rawResults) { 59 super(rawResults); 60 } 61 62 /** 63 * Checks the overall consistency of the results reported by the tool 64 */ 65 @Override 66 public void assertConsistency() { 67 68 // Check exit code 69 assertThat(getExitCode() == 0, "Unexpected exit code: " + getExitCode()); 70 71 // Check Young Gen consistency 72 float NGCMN = getFloatValue("NGCMN"); 73 assertThat(NGCMN >= 0, "NGCMN < 0 (min generation capacity is negative)"); 74 float NGCMX = getFloatValue("NGCMX"); 75 assertThat(NGCMX >= NGCMN, "NGCMN > NGCMX (min generation capacity > max generation capacity)"); 76 77 float NGC = getFloatValue("NGC"); 78 assertThat(NGC >= NGCMN, "NGC < NGCMN (generation capacity < min generation capacity)"); 79 assertThat(NGC <= NGCMX, "NGC > NGCMX (generation capacity > max generation capacity)"); 80 81 float S0C = getFloatValue("S0C"); 82 assertThat(S0C <= NGC, "S0C > NGC (survivor space 0 capacity > new generation capacity)"); 83 84 float S1C = getFloatValue("S1C"); 85 assertThat(S1C <= NGC, "S1C > NGC (survivor space 1 capacity > new generation capacity)"); 86 87 float EC = getFloatValue("EC"); 88 assertThat(EC <= NGC, "EC > NGC (eden space capacity > new generation capacity)"); 89 90 // Verify relative size of NGC and S0C + S1C + EC. 91 // The rule depends on if the tenured GC is parallel or not. 92 // For parallell GC: NGC >= S0C + S1C + EC 93 // For non-parallell GC: NGC == S0C + S1C + EC 94 boolean isTenuredParallelGC = isTenuredParallelGC(); 95 String errMsg = String.format( 96 "NGC %s (S0C + S1C + EC) (NGC = %.1f, S0C = %.1f, S1C = %.1f, EC = %.1f, (S0C + S1C + EC) = %.1f)", 97 isTenuredParallelGC ? "<" : "!=", NGC, S0C, S1C, EC, S0C + S1C + EC); 98 if (isTenuredParallelGC) { 99 assertThat(NGC >= S0C + S1C + EC, errMsg); 100 } else { 101 assertThat(checkFloatIsSum(NGC, S0C, S1C, EC), errMsg); 102 } 103 104 // Check Old Gen consistency 105 float OGCMN = getFloatValue("OGCMN"); 106 assertThat(OGCMN >= 0, "OGCMN < 0 (min generation capacity is negative)"); 107 float OGCMX = getFloatValue("OGCMX"); 108 assertThat(OGCMX >= OGCMN, "OGCMN > OGCMX (min generation capacity > max generation capacity)"); 109 110 float OGC = getFloatValue("OGC"); 111 assertThat(OGC >= OGCMN, "OGC < OGCMN (generation capacity < min generation capacity)"); 112 assertThat(OGC <= OGCMX, "OGC > OGCMX (generation capacity > max generation capacity)"); 113 float OC = getFloatValue("OC"); 114 assertThat(OC == OGC, "OC != OGC (old generation capacity != old space capacity (these values should be equal since old space is made up only from one old generation))"); 115 116 // Check Metaspace consistency 117 float MCMN = getFloatValue("MCMN"); 118 float MCMX = getFloatValue("MCMX"); 119 assertThat(MCMX >= MCMN, "MCMN > MCMX (min generation capacity > max generation capacity)"); 120 float MC = getFloatValue("MC"); 121 assertThat(MC >= MCMN, "MC < MCMN (generation capacity < min generation capacity)"); 122 assertThat(MC <= MCMX, "MGC > MCMX (generation capacity > max generation capacity)"); 123 } 124 125 /** 126 * Check if the tenured generation are currently using a parallel GC. |