46640
|
1 |
/*
|
52910
|
2 |
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
|
46640
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
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
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*/
|
50858
|
23 |
|
|
24 |
|
46640
|
25 |
package org.graalvm.compiler.debug;
|
|
26 |
|
|
27 |
import java.util.Comparator;
|
|
28 |
|
49873
|
29 |
import jdk.internal.vm.compiler.collections.Pair;
|
46640
|
30 |
|
|
31 |
/**
|
|
32 |
* A key for a metric.
|
|
33 |
*/
|
|
34 |
public interface MetricKey {
|
|
35 |
|
|
36 |
/**
|
|
37 |
* Converts a given value for this key to a string, scaling it to a more useful unit of
|
|
38 |
* measurement and appending a suffix indicating the unit where applicable. This representation
|
|
39 |
* is intended for human consumption.
|
|
40 |
*/
|
|
41 |
String toHumanReadableFormat(long value);
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Converts a given value for this key to a CSV format intended for automated data processing.
|
|
45 |
*
|
|
46 |
* @param value
|
|
47 |
* @return a pair where first is the {@code value} with any scaling conversion applied and
|
|
48 |
* second is the unit of measurement used for the first component (this will be the
|
|
49 |
* empty string for a simple counter)
|
|
50 |
*/
|
|
51 |
Pair<String, String> toCSVFormat(long value);
|
|
52 |
|
|
53 |
/**
|
|
54 |
* Gets the name of this key.
|
|
55 |
*/
|
|
56 |
String getName();
|
|
57 |
|
|
58 |
/**
|
|
59 |
* Comparator to sort keys by their names.
|
|
60 |
*/
|
|
61 |
Comparator<MetricKey> NAME_COMPARATOR = new Comparator<MetricKey>() {
|
|
62 |
|
|
63 |
@Override
|
|
64 |
public int compare(MetricKey o1, MetricKey o2) {
|
|
65 |
return o1.getName().compareTo(o2.getName());
|
|
66 |
}
|
|
67 |
|
|
68 |
};
|
|
69 |
|
|
70 |
/**
|
|
71 |
* Sets the documentation for this key.
|
|
72 |
*/
|
|
73 |
MetricKey doc(String string);
|
|
74 |
|
|
75 |
/**
|
|
76 |
* Gets the name to use when listing keys. Note that this may be different from
|
|
77 |
* {@link #getName()}.
|
|
78 |
*
|
|
79 |
* @return {@code null} if this key is derived from another key and so should not be listed
|
|
80 |
*/
|
|
81 |
String getDocName();
|
|
82 |
|
|
83 |
/**
|
|
84 |
* Gets the documentation for this key.
|
|
85 |
*
|
|
86 |
* @return {@code null} if this key has no documentation
|
|
87 |
*/
|
|
88 |
String getDoc();
|
|
89 |
}
|