Package io.perfmark.tracewriter
Class TraceEventWriter
- java.lang.Object
-
- io.perfmark.tracewriter.TraceEventWriter
-
public final class TraceEventWriter extends java.lang.ObjectWrites the PerfMark results to a "Trace Event" JSON file usable by the Chromium Profiler "Catapult". The format is defined at ...This code is NOT API stable, and may be removed in the future, or changed without notice.
- Since:
- 0.16.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classTraceEventWriter.TraceEventObjectprivate static classTraceEventWriter.TraceEventWalker
-
Constructor Summary
Constructors Constructor Description TraceEventWriter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static longgetPid()private static java.nio.file.PathguessDirectory()private static booleanmaybeAddComment(java.io.Writer writer, boolean firstOf)private static java.nio.file.PathpickNextDest(java.nio.file.Path dir)private static java.lang.StringtaskName(Mark mark)private static voidwriteString(java.io.Writer writer, java.lang.String s)private static voidwriteTraceEventObject(java.io.Writer dest, java.util.List<TraceEvent> events)static java.nio.file.PathwriteTraceEvents()Writes trace events the home directory.static voidwriteTraceEvents(java.io.Writer destination)Writes all trace events in JSON format to the given destination.static voidwriteTraceEvents(java.io.Writer destination, java.util.List<? extends MarkList> markLists, long initNanoTime, long nowNanoTime, long pid)Writes the trace events gathered fromStorage.read().
-
-
-
Field Detail
-
logger
private static final java.util.logging.Logger logger
-
HEX_TABLE
private static final java.lang.String HEX_TABLE
- See Also:
- Constant Field Values
-
-
Method Detail
-
writeTraceEvents
@CanIgnoreReturnValue public static java.nio.file.Path writeTraceEvents() throws java.io.IOExceptionWrites trace events the home directory. By default, it prefers the location in$XDG_DATA_HOME/perfmarkenvironment variable. If unset, it attempts to use$HOME/.local/share/perfmark.Authors note: if you are on Windows, or the above defaults aren't right, I'm not really sure where else is a good place to put this data. Please file an issue at https://www.perfmark.io/ if you have a preference.
Updated in 0.17.0 to return the created path.
- Returns:
- the path used to create the trace file.
- Throws:
java.io.IOException- if there is an error writing to the file.
-
writeTraceEvents
public static void writeTraceEvents(java.io.Writer destination) throws java.io.IOExceptionWrites all trace events in JSON format to the given destination.- Parameters:
destination- the destination for the JSON data.- Throws:
java.io.IOException- if there are errors build the JSON, or can't write to the destination.
-
writeTraceEvents
public static void writeTraceEvents(java.io.Writer destination, java.util.List<? extends MarkList> markLists, long initNanoTime, long nowNanoTime, long pid) throws java.io.IOExceptionWrites the trace events gathered fromStorage.read(). This method is not API stable. It will be eventually.- Parameters:
destination- the destination for the JSON data.markLists- the data to use to build the trace event JSONinitNanoTime- the time PerfMark classes were first loaded as specified bySystem.nanoTime()nowNanoTime- the current time as specified bySystem.nanoTime().pid- the PID of the current process.- Throws:
java.io.IOException- if there are errors build the JSON, or can't write to the destination.
-
writeTraceEventObject
private static void writeTraceEventObject(java.io.Writer dest, java.util.List<TraceEvent> events) throws java.io.IOException- Throws:
java.io.IOException
-
maybeAddComment
private static boolean maybeAddComment(java.io.Writer writer, boolean firstOf) throws java.io.IOException- Throws:
java.io.IOException
-
pickNextDest
private static java.nio.file.Path pickNextDest(java.nio.file.Path dir) throws java.io.IOException- Throws:
java.io.IOException
-
guessDirectory
private static java.nio.file.Path guessDirectory() throws java.io.IOException- Throws:
java.io.IOException
-
getPid
private static long getPid()
-
taskName
private static java.lang.String taskName(Mark mark)
-
writeString
private static void writeString(java.io.Writer writer, java.lang.String s) throws java.io.IOException- Throws:
java.io.IOException
-
-