Summary
Add the command-line switch --exact
to the jfr print
command.
Problem
The jfr print
command allows users to print events from a .jfr
file in a human-readable format, for example:
$ jfr print recording.jfr
jdk.FileRead {
startTime = 16:36:14.373 (2025-04-09)
duration = 2.02 ms
path = "/var/folders/g0/cdrkqsy90rz1zq_1c8_xcv4h0000gn/T/+~JF223373.tmp"
bytesRead = 5.2 MB
endOfFile = false
eventThread = "AWT-EventQueue-0" (javaThreadId = 32)
...
}
This is usually sufficient to see what is happening, but for verification purposes or correlation with other sources, such as perf
output or log files, the exact value is sometimes required. One way to view the exact value is to pass --json
to jfr print
, which displays the recording in a machine-readable format.
However, this approach makes the output extremely verbose and cumbersome to read. There is a need to display exact values when pretty-printing a recording.
Solution
Add the command-line switch --exact
so that jfr print
outputs timestamps, time spans, percentages, and byte values with full precision, for example:
$ jfr print --exact recording.jfr
jdk.FileRead {
startTime = 16:36:14.373600833 (2025-04-09)
duration = 0.0020170800 s
path = "/var/folders/g0/cdrkqsy90rz1zq_1c8_xcv4h0000gn/T/+~JF223373.tmp"
bytesRead = 5458957 bytes
endOfFile = false
eventThread = "AWT-EventQueue-0" (javaThreadId = 32)
...
}
Specification
src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Print.java
public List<String> getOptionSyntax() {
List<String> list = new ArrayList<>();
- list.add("[--xml|--json]");
+ list.add("[--xml|--json|--exact]");
list.add("[--categories <filter>]");
list.add("[--events <filter>]");
list.add("[--stack-depth <depth>]");
@@ -73,6 +73,8 @@ public void displayOptionUsage(PrintStream stream) {
stream.println();
stream.println(" --json Print recording in JSON format");
stream.println();
+ stream.println(" --exact Pretty-print numbers and timestamps with full precision.");
+ stream.println();
stream.println(" --categories <filter> Select events matching a category name.");
- csr of
-
JDK-8353614 JFR: jfr print --exact
-
- Resolved
-