test/hotspot/jtreg/serviceability/tmtools/jstat/utils/JstatResults.java
author ysuenaga
Sun, 20 May 2018 20:25:51 +0900
changeset 50190 6f548c41a4fc
parent 47216 71c04702a3d5
permissions -rw-r--r--
8202466: Test serviceability/tmtools/jstat/GcTest01.java fails: Number of concurrent GC events is 1, but CGCT is 0 Reviewed-by: cjplummer, sspitsyn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35493
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
     1
/*
50190
6f548c41a4fc 8202466: Test serviceability/tmtools/jstat/GcTest01.java fails: Number of concurrent GC events is 1, but CGCT is 0
ysuenaga
parents: 47216
diff changeset
     2
 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
35493
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
     4
 *
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
     7
 * published by the Free Software Foundation.
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
     8
 *
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    13
 * accompanied this code).
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    14
 *
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    18
 *
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    21
 * questions.
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    22
 */
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    23
package utils;
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    24
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    25
import common.ToolResults;
46827
8d2f07a78ac7 8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale.
goetz
parents: 43933
diff changeset
    26
import java.text.NumberFormat;
8d2f07a78ac7 8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale.
goetz
parents: 43933
diff changeset
    27
import java.text.ParseException;
8d2f07a78ac7 8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale.
goetz
parents: 43933
diff changeset
    28
35493
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    29
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    30
/**
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    31
 * Results of running the jstat tool Concrete subclasses will detail the jstat
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    32
 * tool options
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    33
 */
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    34
abstract public class JstatResults extends ToolResults {
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    35
43933
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
    36
    private static final float FLOAT_COMPARISON_TOLERANCE = 0.0011f;
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
    37
35493
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    38
    public JstatResults(ToolResults rawResults) {
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    39
        super(rawResults);
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    40
    }
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    41
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    42
    /**
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    43
     * Gets a string result from the column labeled 'name'
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    44
     *
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    45
     * @param name - name of the column
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    46
     * @return the result
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    47
     */
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    48
    public String getStringValue(String name) {
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    49
        int valueNdx = new StringOfValues(getStdoutLine(0)).getIndex(name);
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    50
        return new StringOfValues(getStdoutLine(1)).getValue(valueNdx);
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    51
    }
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    52
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    53
    /**
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    54
     * Gets a float result from the column labeled 'name'
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    55
     *
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    56
     * @param name - name of the column
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    57
     * @return the result
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    58
     */
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    59
    public float getFloatValue(String name) {
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    60
        int valueNdx = new StringOfValues(getStdoutLine(0)).getIndex(name);
46827
8d2f07a78ac7 8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale.
goetz
parents: 43933
diff changeset
    61
        // Let the parsing use the current locale format.
8d2f07a78ac7 8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale.
goetz
parents: 43933
diff changeset
    62
        try {
8d2f07a78ac7 8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale.
goetz
parents: 43933
diff changeset
    63
            return NumberFormat.getInstance().parse(new StringOfValues(getStdoutLine(1)).getValue(valueNdx)).floatValue();
8d2f07a78ac7 8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale.
goetz
parents: 43933
diff changeset
    64
        } catch (ParseException e) {
8d2f07a78ac7 8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale.
goetz
parents: 43933
diff changeset
    65
            throw new NumberFormatException(e.getMessage());
8d2f07a78ac7 8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale.
goetz
parents: 43933
diff changeset
    66
        }
8d2f07a78ac7 8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale.
goetz
parents: 43933
diff changeset
    67
35493
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    68
    }
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    69
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    70
    /**
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    71
     * Gets an integer result from the column labeled 'name'
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    72
     *
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    73
     * @param name - name of the column
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    74
     * @return the result
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    75
     */
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    76
    public int getIntValue(String name) {
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    77
        int valueNdx = new StringOfValues(getStdoutLine(0)).getIndex(name);
46827
8d2f07a78ac7 8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale.
goetz
parents: 43933
diff changeset
    78
        try {
8d2f07a78ac7 8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale.
goetz
parents: 43933
diff changeset
    79
            return NumberFormat.getInstance().parse(new StringOfValues(getStdoutLine(1)).getValue(valueNdx)).intValue();
8d2f07a78ac7 8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale.
goetz
parents: 43933
diff changeset
    80
        } catch (ParseException e) {
8d2f07a78ac7 8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale.
goetz
parents: 43933
diff changeset
    81
            throw new NumberFormatException(e.getMessage());
8d2f07a78ac7 8185112: [TESTBUG] Serviceability tests cannot parse float if non US locale.
goetz
parents: 43933
diff changeset
    82
        }
35493
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    83
    }
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    84
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    85
    /**
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    86
     * Checks if a column with a given name exists
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    87
     *
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    88
     * @param name - name of the column
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    89
     * @return true if the column exist, false otherwise
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    90
     */
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    91
    public boolean valueExists(String name) {
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    92
        return new StringOfValues(getStdoutLine(0)).getIndex(name) != -1;
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    93
    }
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    94
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    95
    /**
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    96
     * Helper function to assert the increase of the GC events between 2
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    97
     * measurements
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    98
     *
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
    99
     * @param measurement1 -first measurement
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   100
     * @param measurement2 -first measurement
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   101
     */
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   102
    public static void assertGCEventsIncreased(JstatResults measurement1, JstatResults measurement2) {
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   103
        assertThat(measurement2.getFloatValue("YGC") > measurement1.getFloatValue("YGC"), "YGC didn't increase between measurements 1 and 2");
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   104
        assertThat(measurement2.getFloatValue("FGC") > measurement1.getFloatValue("FGC"), "FGC didn't increase between measurements 2 and 3");
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   105
    }
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   106
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   107
    /**
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   108
     * Helper function to assert the increase of the GC time between 2
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   109
     * measurements
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   110
     *
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   111
     * @param measurement1 -first measurement
50190
6f548c41a4fc 8202466: Test serviceability/tmtools/jstat/GcTest01.java fails: Number of concurrent GC events is 1, but CGCT is 0
ysuenaga
parents: 47216
diff changeset
   112
     * @param measurement2 -second measurement
35493
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   113
     */
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   114
    public static void assertGCTimeIncreased(JstatResults measurement1, JstatResults measurement2) {
50190
6f548c41a4fc 8202466: Test serviceability/tmtools/jstat/GcTest01.java fails: Number of concurrent GC events is 1, but CGCT is 0
ysuenaga
parents: 47216
diff changeset
   115
        assertThat(measurement2.getFloatValue("YGCT") >= measurement1.getFloatValue("YGCT"), "YGCT time rewinded between measurements 1 and 2");
6f548c41a4fc 8202466: Test serviceability/tmtools/jstat/GcTest01.java fails: Number of concurrent GC events is 1, but CGCT is 0
ysuenaga
parents: 47216
diff changeset
   116
        assertThat(measurement2.getFloatValue("FGCT") >= measurement1.getFloatValue("FGCT"), "FGCT time rewinded between measurements 1 and 2");
6f548c41a4fc 8202466: Test serviceability/tmtools/jstat/GcTest01.java fails: Number of concurrent GC events is 1, but CGCT is 0
ysuenaga
parents: 47216
diff changeset
   117
        assertThat(measurement2.getFloatValue("GCT") >= measurement1.getFloatValue("GCT"), "GCT time rewinded between measurements 1 and 2");
35493
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   118
    }
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   119
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   120
    /**
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   121
     * Helper function to assert the utilization of the space
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   122
     *
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   123
     * @param measurement - measurement results to analyze
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   124
     * @param targetMemoryUsagePercent -assert that not less than this amount of
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   125
     * space has been utilized
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   126
     */
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   127
    public static void assertSpaceUtilization(JstatResults measurement, float targetMemoryUsagePercent) {
43933
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   128
        assertSpaceUtilization(measurement, targetMemoryUsagePercent, targetMemoryUsagePercent);
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   129
    }
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   130
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   131
    /**
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   132
     * Helper function to assert the utilization of the space
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   133
     *
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   134
     * @param measurement - measurement results to analyze
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   135
     * @param targetMetaspaceUsagePercent -assert that not less than this amount
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   136
     * of metaspace has been utilized
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   137
     * @param targetOldSpaceUsagePercent -assert that not less than this amount
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   138
     * of old space has been utilized
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   139
     */
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   140
    public static void assertSpaceUtilization(JstatResults measurement, float targetMetaspaceUsagePercent,
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   141
            float targetOldSpaceUsagePercent) {
35493
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   142
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   143
        if (measurement.valueExists("OU")) {
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   144
            float OC = measurement.getFloatValue("OC");
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   145
            float OU = measurement.getFloatValue("OU");
43933
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   146
            assertThat((OU / OC) > targetOldSpaceUsagePercent, "Old space utilization should be > "
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   147
                    + (targetOldSpaceUsagePercent * 100) + "%, actually OU / OC = " + (OU / OC));
35493
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   148
        }
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   149
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   150
        if (measurement.valueExists("MU")) {
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   151
            float MC = measurement.getFloatValue("MC");
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   152
            float MU = measurement.getFloatValue("MU");
43933
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   153
            assertThat((MU / MC) > targetMetaspaceUsagePercent, "Metaspace utilization should be > "
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   154
                    + (targetMetaspaceUsagePercent * 100) + "%, actually MU / MC = " + (MU / MC));
35493
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   155
        }
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   156
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   157
        if (measurement.valueExists("O")) {
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   158
            float O = measurement.getFloatValue("O");
43933
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   159
            assertThat(O > targetOldSpaceUsagePercent * 100, "Old space utilization should be > "
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   160
                    + (targetOldSpaceUsagePercent * 100) + "%, actually O = " + O);
35493
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   161
        }
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   162
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   163
        if (measurement.valueExists("M")) {
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   164
            float M = measurement.getFloatValue("M");
43933
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   165
            assertThat(M > targetMetaspaceUsagePercent * 100, "Metaspace utilization should be > "
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   166
                    + (targetMetaspaceUsagePercent * 100) + "%, actually M = " + M);
35493
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   167
        }
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   168
    }
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   169
43933
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   170
    public static void assertThat(boolean result, String message) {
35493
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   171
        if (!result) {
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   172
            throw new RuntimeException(message);
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   173
        }
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   174
    }
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   175
43933
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   176
    public static boolean checkFloatIsSum(float sum, float... floats) {
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   177
        for (float f : floats) {
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   178
            sum -= f;
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   179
        }
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   180
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   181
        return Math.abs(sum) <= FLOAT_COMPARISON_TOLERANCE;
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   182
    }
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   183
85ee551f3948 8170737: Not enough old space utilisation
mchernov
parents: 35493
diff changeset
   184
    abstract public void assertConsistency();
35493
863fb33f9940 8130063: Refactoring tmtools jstat and jstack tests to jtreg
akulyakh
parents:
diff changeset
   185
}