test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitor.java
changeset 54659 62d6baca22fc
parent 52722 19de50eb561d
equal deleted inserted replaced
54658:a86c5059749b 54659:62d6baca22fc
     1 /*
     1 /*
     2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright (c) 2018, Google and/or its affiliates. All rights reserved.
     3  * Copyright (c) 2018, 2019, Google and/or its affiliates. All rights reserved.
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5  *
     5  *
     6  * This code is free software; you can redistribute it and/or modify it
     6  * This code is free software; you can redistribute it and/or modify it
     7  * under the terms of the GNU General Public License version 2 only, as
     7  * under the terms of the GNU General Public License version 2 only, as
     8  * published by the Free Software Foundation.
     8  * published by the Free Software Foundation.
   261   public static boolean garbageContains(Frame[] frames) {
   261   public static boolean garbageContains(Frame[] frames) {
   262     return garbageContains(frames, getCheckLines());
   262     return garbageContains(frames, getCheckLines());
   263   }
   263   }
   264 
   264 
   265   public static boolean statsHaveExpectedNumberSamples(int expected, int acceptedErrorPercentage) {
   265   public static boolean statsHaveExpectedNumberSamples(int expected, int acceptedErrorPercentage) {
   266     double actual = getEventStorageElementCount();
   266     double actual = sampledEvents();
   267     double diffPercentage = Math.abs(actual - expected) / expected;
   267     double diffPercentage = 100 * Math.abs(actual - expected) / expected;
       
   268 
       
   269     if (diffPercentage >= acceptedErrorPercentage) {
       
   270       System.err.println("Unexpected high difference percentage: " + diffPercentage
       
   271           + " due to the count being " + actual + " instead of " + expected);
       
   272     }
   268     return diffPercentage < acceptedErrorPercentage;
   273     return diffPercentage < acceptedErrorPercentage;
   269   }
   274   }
   270 
   275 
   271   public static void setAllocationIterations(int iterations) {
   276   public static void setAllocationIterations(int iterations) {
   272     allocationIterations = iterations;
   277     allocationIterations = iterations;