Skip to content

Commit 2971ce1

Browse files
authored
Display frame types when analyzing top frames. (#13670)
This helps understand if a given frame is interpreted, compiled or inlined for instance.
1 parent 4404aa3 commit 2971ce1

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

build-tools/build-infra/src/main/java/org/apache/lucene/gradle/ProfileResults.java

+14-10
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
*/
4242
public class ProfileResults {
4343
/** Formats a frame to a formatted line. This is deduplicated on! */
44-
static String frameToString(RecordedFrame frame, boolean lineNumbers) {
44+
static String frameToString(RecordedFrame frame, boolean lineNumbers, boolean frameTypes) {
4545
StringBuilder builder = new StringBuilder();
4646
RecordedMethod method = frame.getMethod();
4747
RecordedClass clazz = method.getType();
@@ -55,13 +55,14 @@ static String frameToString(RecordedFrame frame, boolean lineNumbers) {
5555
builder.append("#");
5656
builder.append(method.getName());
5757
builder.append("()");
58-
if (lineNumbers) {
58+
if (lineNumbers && frame.getLineNumber() != -1) {
5959
builder.append(":");
60-
if (frame.getLineNumber() == -1) {
61-
builder.append("(" + frame.getType() + " code)");
62-
} else {
63-
builder.append(frame.getLineNumber());
64-
}
60+
builder.append(frame.getLineNumber());
61+
}
62+
if (clazz != null && frameTypes) {
63+
builder.append(" [");
64+
builder.append(frame.getType());
65+
builder.append(" code]");
6566
}
6667
return builder.toString();
6768
}
@@ -77,6 +78,8 @@ static String frameToString(RecordedFrame frame, boolean lineNumbers) {
7778
public static final String COUNT_DEFAULT = "10";
7879
public static final String LINENUMBERS_KEY = "tests.profile.linenumbers";
7980
public static final String LINENUMBERS_DEFAULT = "false";
81+
public static final String FRAMETYPES_KEY = "tests.profile.frametypes";
82+
public static final String FRAMETYPES_DEFAULT = "true";
8083

8184
/**
8285
* Driver method, for testing standalone.
@@ -92,7 +95,8 @@ public static void main(String[] args) throws IOException {
9295
System.getProperty(MODE_KEY, MODE_DEFAULT),
9396
Integer.parseInt(System.getProperty(STACKSIZE_KEY, STACKSIZE_DEFAULT)),
9497
Integer.parseInt(System.getProperty(COUNT_KEY, COUNT_DEFAULT)),
95-
Boolean.parseBoolean(System.getProperty(LINENUMBERS_KEY, LINENUMBERS_DEFAULT)));
98+
Boolean.parseBoolean(System.getProperty(LINENUMBERS_KEY, LINENUMBERS_DEFAULT)),
99+
Boolean.parseBoolean(System.getProperty(FRAMETYPES_KEY, FRAMETYPES_DEFAULT)));
96100
}
97101

98102
/** true if we care about this event */
@@ -152,7 +156,7 @@ private static String pad(String input) {
152156

153157
/** Process all the JFR files passed in args and print a merged summary. */
154158
public static void printReport(
155-
List<String> files, String mode, int stacksize, int count, boolean lineNumbers)
159+
List<String> files, String mode, int stacksize, int count, boolean lineNumbers, boolean frameTypes)
156160
throws IOException {
157161
if (!"cpu".equals(mode) && !"heap".equals(mode)) {
158162
throw new IllegalArgumentException("tests.profile.mode must be one of (cpu,heap)");
@@ -181,7 +185,7 @@ public static void printReport(
181185
if (stack.length() > 0) {
182186
stack.append("\n").append(framePadding).append(" at ");
183187
}
184-
stack.append(frameToString(trace.getFrames().get(i), lineNumbers));
188+
stack.append(frameToString(trace.getFrames().get(i), lineNumbers, frameTypes));
185189
}
186190
String line = stack.toString();
187191
SimpleEntry<String, Long> entry =

0 commit comments

Comments
 (0)