public final class CPUTracer extends Object implements Closeable
The tracer counts how many times each of the elements of interest (e.g. functions, statements, etc.) are executed.
Usage example:
Contextcontext =Context.create();CPUTracertracer =CPUTracer.find(context.getEngine()); tracer.setCollecting(true); context.eval("...", "..."); tracer.setCollecting(false); tracer.close(); // Read information about execution counts of elements. for (CPUTracer.Payload p : tracer.getPayloads()) { finalStringrootName = p.getRootName(); final long count = p.getCount(); }
| Modifier and Type | Class and Description |
|---|---|
static class |
CPUTracer.Payload
Holds data on how many times a section of source code was executed.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearData()
Erases all the data gathered by the tracer.
|
void |
close()
Closes the tracer for fuhrer use, deleting all the gathered data.
|
static CPUTracer |
find(org.graalvm.polyglot.Engine engine)
Finds
CPUTracer associated with given engine. |
com.oracle.truffle.api.instrumentation.SourceSectionFilter |
getFilter() |
Collection<CPUTracer.Payload> |
getPayloads() |
boolean |
isCollecting() |
void |
setCollecting(boolean collecting)
Controls whether the tracer is collecting data or not.
|
void |
setFilter(com.oracle.truffle.api.instrumentation.SourceSectionFilter filter)
Sets the
filter for the tracer. |
public static CPUTracer find(org.graalvm.polyglot.Engine engine)
CPUTracer associated with given engine.engine - the engine to find debugger forCPUTracerpublic void setCollecting(boolean collecting)
collecting - the new state of the tracer.public boolean isCollecting()
public void setFilter(com.oracle.truffle.api.instrumentation.SourceSectionFilter filter)
filter for the tracer. This allows the tracer to trace
only parts of the executed source code.filter - The filter describing which part of the source code to tracepublic com.oracle.truffle.api.instrumentation.SourceSectionFilter getFilter()
public Collection<CPUTracer.Payload> getPayloads()
public void clearData()
public void close()
close in interface Closeableclose in interface AutoCloseable