hotspot/test/serviceability/tmtools/jstat/utils/JstatGcCapacityResults.java
changeset 43933 85ee551f3948
parent 35945 f532c5c62540
equal deleted inserted replaced
43433:acc1d9072823 43933:85ee551f3948
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    60     }
    60     }
    61 
    61 
    62     /**
    62     /**
    63      * Checks the overall consistency of the results reported by the tool
    63      * Checks the overall consistency of the results reported by the tool
    64      */
    64      */
       
    65     @Override
    65     public void assertConsistency() {
    66     public void assertConsistency() {
    66 
    67 
    67         // Check exit code
    68         // Check exit code
    68         assertThat(getExitCode() == 0, "Unexpected exit code: " + getExitCode());
    69         assertThat(getExitCode() == 0, "Unexpected exit code: " + getExitCode());
    69 
    70 
   115         float MCMX = getFloatValue("MCMX");
   116         float MCMX = getFloatValue("MCMX");
   116         assertThat(MCMX >= MCMN, "MCMN > MCMX (min generation capacity > max generation capacity)");
   117         assertThat(MCMX >= MCMN, "MCMN > MCMX (min generation capacity > max generation capacity)");
   117         float MC = getFloatValue("MC");
   118         float MC = getFloatValue("MC");
   118         assertThat(MC >= MCMN, "MC < MCMN (generation capacity < min generation capacity)");
   119         assertThat(MC >= MCMN, "MC < MCMN (generation capacity < min generation capacity)");
   119         assertThat(MC <= MCMX, "MGC > MCMX (generation capacity > max generation capacity)");
   120         assertThat(MC <= MCMX, "MGC > MCMX (generation capacity > max generation capacity)");
   120 
       
   121 
       
   122     }
   121     }
   123 
   122 
   124     /**
   123     /**
   125      * Check if the tenured generation are currently using a parallel GC.
   124      * Check if the tenured generation are currently using a parallel GC.
   126      */
   125      */
   137         } catch (Exception e) {
   136         } catch (Exception e) {
   138             e.printStackTrace();
   137             e.printStackTrace();
   139         }
   138         }
   140         return false;
   139         return false;
   141     }
   140     }
   142 
       
   143     private static final float FLOAT_COMPARISON_TOLERANCE = 0.0011f;
       
   144 
       
   145     private static boolean checkFloatIsSum(float sum, float... floats) {
       
   146         for (float f : floats) {
       
   147             sum -= f;
       
   148         }
       
   149 
       
   150         return Math.abs(sum) <= FLOAT_COMPARISON_TOLERANCE;
       
   151     }
       
   152 
       
   153     private void assertThat(boolean b, String message) {
       
   154         if (!b) {
       
   155             throw new RuntimeException(message);
       
   156         }
       
   157     }
       
   158 
       
   159 }
   141 }