提交 31c92d61 编写于 作者: C cito

8223697: jfr tool can't format duration values greater than 1 minute

Reviewed-by: egahlin
上级 fe166648
......@@ -57,6 +57,9 @@ import jdk.jfr.internal.Utils;
* This class is also used by {@link RecordedObject#toString()}
*/
public final class PrettyWriter extends EventPrintWriter {
private static final Duration MILLSECOND = Duration.ofMillis(1);
private static final Duration SECOND = Duration.ofSeconds(1);
private static final Duration MINUTE = Duration.ofMinutes(1);
private static final String TYPE_OLD_OBJECT = Type.TYPES_PREFIX + "OldObject";
private final static DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("HH:mm:ss.SSS");
private final static Long ZERO = 0L;
......@@ -548,19 +551,14 @@ public final class PrettyWriter extends EventPrintWriter {
println("N/A");
return true;
}
double s = d.toNanosPart() / 1000_000_000.0 + d.toSecondsPart();
if (s < 1.0) {
if (s < 0.001) {
println(String.format("%.3f", s * 1_000_000) + " us");
} else {
println(String.format("%.3f", s * 1_000) + " ms");
}
if(d.compareTo(MILLSECOND) < 0){
println(String.format("%.3f us", (double)d.toNanos() / 1_000));
} else if(d.compareTo(SECOND) < 0){
println(String.format("%.3f ms", (double)d.toNanos() / 1_000_000));
} else if(d.compareTo(MINUTE) < 0){
println(String.format("%.3f s", (double)d.toMillis() / 1_000));
} else {
if (s < 1000.0) {
println(String.format("%.3f", s) + " s");
} else {
println(String.format("%.0f", s) + " s");
}
println(String.format("%d s", d.toSeconds()));
}
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册