41
41
*/
42
42
public class ProfileResults {
43
43
/** 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 ) {
45
45
StringBuilder builder = new StringBuilder ();
46
46
RecordedMethod method = frame .getMethod ();
47
47
RecordedClass clazz = method .getType ();
@@ -55,13 +55,14 @@ static String frameToString(RecordedFrame frame, boolean lineNumbers) {
55
55
builder .append ("#" );
56
56
builder .append (method .getName ());
57
57
builder .append ("()" );
58
- if (lineNumbers ) {
58
+ if (lineNumbers && frame . getLineNumber () != - 1 ) {
59
59
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]" );
65
66
}
66
67
return builder .toString ();
67
68
}
@@ -77,6 +78,8 @@ static String frameToString(RecordedFrame frame, boolean lineNumbers) {
77
78
public static final String COUNT_DEFAULT = "10" ;
78
79
public static final String LINENUMBERS_KEY = "tests.profile.linenumbers" ;
79
80
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" ;
80
83
81
84
/**
82
85
* Driver method, for testing standalone.
@@ -92,7 +95,8 @@ public static void main(String[] args) throws IOException {
92
95
System .getProperty (MODE_KEY , MODE_DEFAULT ),
93
96
Integer .parseInt (System .getProperty (STACKSIZE_KEY , STACKSIZE_DEFAULT )),
94
97
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 )));
96
100
}
97
101
98
102
/** true if we care about this event */
@@ -152,7 +156,7 @@ private static String pad(String input) {
152
156
153
157
/** Process all the JFR files passed in args and print a merged summary. */
154
158
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 )
156
160
throws IOException {
157
161
if (!"cpu" .equals (mode ) && !"heap" .equals (mode )) {
158
162
throw new IllegalArgumentException ("tests.profile.mode must be one of (cpu,heap)" );
@@ -181,7 +185,7 @@ public static void printReport(
181
185
if (stack .length () > 0 ) {
182
186
stack .append ("\n " ).append (framePadding ).append (" at " );
183
187
}
184
- stack .append (frameToString (trace .getFrames ().get (i ), lineNumbers ));
188
+ stack .append (frameToString (trace .getFrames ().get (i ), lineNumbers , frameTypes ));
185
189
}
186
190
String line = stack .toString ();
187
191
SimpleEntry <String , Long > entry =
0 commit comments