mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-19 06:45:17 +00:00
8309959: JFR: Display N/A for missing data amount
Reviewed-by: mgronlun, stuefe
This commit is contained in:
parent
4c18b9e1fa
commit
9872a14192
@ -121,11 +121,13 @@ public final class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
// handle Long.MIN_VALUE as a special case since its absolute value is negative
|
||||
private static String formatDataAmount(String formatter, long amount) {
|
||||
int exp = (amount == Long.MIN_VALUE) ? 6 : (int) (Math.log(Math.abs(amount)) / Math.log(1024));
|
||||
char unitPrefix = "kMGTPE".charAt(exp - 1);
|
||||
return String.format(formatter, amount / Math.pow(1024, exp), unitPrefix);
|
||||
if (amount == Long.MIN_VALUE) {
|
||||
return "N/A";
|
||||
}
|
||||
int exp = (int) (Math.log(Math.abs(amount)) / Math.log(1024));
|
||||
char unit = "kMGTPE".charAt(exp - 1);
|
||||
return String.format(formatter, amount / Math.pow(1024, exp), unit);
|
||||
}
|
||||
|
||||
public static String formatBytesCompact(long bytes) {
|
||||
|
||||
@ -146,11 +146,13 @@ public final class ValueFormatter {
|
||||
return name;
|
||||
}
|
||||
|
||||
// handle Long.MIN_VALUE as a special case since its absolute value is negative
|
||||
private static String formatDataAmount(String formatter, long amount) {
|
||||
int exp = (amount == Long.MIN_VALUE) ? 6 : (int) (Math.log(Math.abs(amount)) / Math.log(1024));
|
||||
char unitPrefix = "kMGTPE".charAt(exp - 1);
|
||||
return String.format(formatter, amount / Math.pow(1024, exp), unitPrefix);
|
||||
if (amount == Long.MIN_VALUE) {
|
||||
return "N/A";
|
||||
}
|
||||
int exp = (int) (Math.log(Math.abs(amount)) / Math.log(1024));
|
||||
char unit = "kMGTPE".charAt(exp - 1);
|
||||
return String.format(formatter, amount / Math.pow(1024, exp), unit);
|
||||
}
|
||||
|
||||
public static String formatBytesCompact(long bytes) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user