File tree Expand file tree Collapse file tree 4 files changed +49
-15
lines changed
src/org/graalvm/visualvm/modules/tracer/jvm/resources
src/org/graalvm/visualvm/modules/tracer Expand file tree Collapse file tree 4 files changed +49
-15
lines changed Original file line number Diff line number Diff line change @@ -3,4 +3,4 @@ AutoUpdate-Show-In-Client: false
3
3
OpenIDE-Module: org.graalvm.visualvm.modules.tracer/2
4
4
OpenIDE-Module-Install: org/graalvm/visualvm/modules/tracer/impl/TracerViewProvider.class
5
5
OpenIDE-Module-Localizing-Bundle: org/graalvm/visualvm/modules/tracer/impl/Bundle.properties
6
- OpenIDE-Module-Specification-Version: 2.0
6
+ OpenIDE-Module-Specification-Version: 2.1
Original file line number Diff line number Diff line change @@ -82,6 +82,12 @@ public String getUnits(int format) {
82
82
* Uses Number.getPercentInstance().toString().
83
83
*/
84
84
public static final ItemValueFormatter DEFAULT_PERCENT = new Percent ();
85
+ /**
86
+ * Predefined formatter for bytes/sec values. Uses B/s (Bytes/sec) for tooltip,
87
+ * details table and export, uses kB/s for units (min/max values).
88
+ * Uses Number.getInstance().toString().
89
+ */
90
+ public static final ItemValueFormatter DEFAULT_BYTES_PER_SEC = new BytesSec ();
85
91
86
92
87
93
/**
@@ -184,6 +190,43 @@ public String getUnits(int format) {
184
190
185
191
}
186
192
193
+ /**
194
+ * Predefined formatter for bytes/sec values. Uses B/s (Bytes/sec) for tooltip,
195
+ * details table and export, uses kB/s for units (min/max values).
196
+ * Uses Number.getInstance().toString().
197
+ */
198
+ private static final class BytesSec extends ItemValueFormatter {
199
+
200
+ private static final NumberFormat FORMAT = NumberFormat .getInstance ();
201
+
202
+
203
+ public String formatValue (long value , int format ) {
204
+ switch (format ) {
205
+ case FORMAT_TOOLTIP :
206
+ case FORMAT_DETAILS :
207
+ case FORMAT_EXPORT :
208
+ return FORMAT .format (value );
209
+ case FORMAT_UNITS :
210
+ String est = value == 0 ? "" : "~" ;
211
+ return est + FORMAT .format (Math .round (value / 1024.0 ));
212
+ default :
213
+ return null ;
214
+ }
215
+ }
216
+
217
+ public String getUnits (int format ) {
218
+ switch (format ) {
219
+ case FORMAT_TOOLTIP :
220
+ case FORMAT_DETAILS :
221
+ case FORMAT_EXPORT :
222
+ return "B/s" ;
223
+ case FORMAT_UNITS :
224
+ return "kB/s" ;
225
+ default :
226
+ return null ;
227
+ }
228
+ }
229
+ }
187
230
188
231
/**
189
232
* Predefined formatter for percent values with custom factor.
Original file line number Diff line number Diff line change 12
12
<compile-dependency />
13
13
<run-dependency >
14
14
<release-version >2</release-version >
15
- <specification-version >2.0 </specification-version >
15
+ <specification-version >2.1 </specification-version >
16
16
</run-dependency >
17
17
</dependency >
18
18
<dependency >
Original file line number Diff line number Diff line change 37
37
var btraceDeployer = btraceDeployerClass ? btraceDeployerClass . instance ( ) : undefined ;
38
38
39
39
40
- var Format_KBPS = {
41
- formatValue : function ( value , format ) {
42
- return ( value / 1024 ) . toFixed ( 2 ) ;
43
- } ,
44
- getUnits : function ( format ) {
45
- return "kB/s"
46
- }
47
- }
48
-
49
40
function getGCRunProvider ( on ) {
50
41
return function ( timestamp ) {
51
42
if ( this . delta == undefined ) {
@@ -310,15 +301,15 @@ VisualVM.Tracer.addPackages([{
310
301
value : mbeanAttribute ( "btrace:name=JavaIOStats" , "fileReadRate" ) ,
311
302
presenter : {
312
303
lineColor : Color . GREEN ,
313
- format : Format_KBPS
304
+ format : ItemValueFormatter . DEFAULT_BYTES_PER_SEC
314
305
}
315
306
} ,
316
307
{
317
308
name : "Writing rate" ,
318
309
value : mbeanAttribute ( "btrace:name=JavaIOStats" , "fileWriteRate" ) ,
319
310
presenter : {
320
311
lineColor : Color . RED ,
321
- format : Format_KBPS
312
+ format : ItemValueFormatter . DEFAULT_BYTES_PER_SEC
322
313
}
323
314
}
324
315
]
@@ -341,15 +332,15 @@ VisualVM.Tracer.addPackages([{
341
332
value : mbeanAttribute ( "btrace:name=JavaIOStats" , "nioReadRate" ) ,
342
333
presenter : {
343
334
lineColor : Color . GREEN ,
344
- format : Format_KBPS
335
+ format : ItemValueFormatter . DEFAULT_BYTES_PER_SEC
345
336
}
346
337
} ,
347
338
{
348
339
name : "Writing rate" ,
349
340
value : mbeanAttribute ( "btrace:name=JavaIOStats" , "nioWriteRate" ) ,
350
341
presenter : {
351
342
lineColor : Color . RED ,
352
- format : Format_KBPS
343
+ format : ItemValueFormatter . DEFAULT_BYTES_PER_SEC
353
344
}
354
345
}
355
346
]
You can’t perform that action at this time.
0 commit comments