Class SpecializationStatistics

java.lang.Object
com.oracle.truffle.api.dsl.SpecializationStatistics

public final class SpecializationStatistics extends Object
Represents a specialization statistics utiltiy that can be entered to collect additional statistics about Truffle DSL nodes. In order for the statistics to be useful the nodes need to be regenerated using the -Atruffle.dsl.GenerateSpecializationStatistics=true flag or using the SpecializationStatistics.AlwaysEnabled annotation.

The easiest way to use this utility is to enable the --engine.SpecializationStatistics polyglot option. This should print the histogram when the engine is closed.

See also the usage tutorial on the website.

Since:
20.3
  • Method Details

    • hasData

      public boolean hasData()
      Returns true if the statistics did collect any data, else false.
      Since:
      20.3
    • printHistogram

      public void printHistogram(PrintWriter writer)
      Prints the specialization histogram to the provided writer. Does not print anything if no data was collected.
      Since:
      20.3
      See Also:
    • printHistogram

      public void printHistogram(PrintStream stream)
      Prints the specialization histogram to the provided stream. Does not print anything if no data was collected.
      Since:
      20.3
      See Also:
    • create

      public static SpecializationStatistics create()
      Creates a new specialization statistics instance. Note specialization statistics need to be entered to collect data on a thread.
      Since:
      20.3
    • enter

      public SpecializationStatistics enter()
      Enters this specialization instance object on the current thread. After entering a specialization statistics instance will gather statistics for all nodes with specializations that were created on this entered thread. Multiple threads may be entered at the same time. The caller must make sure to leave(SpecializationStatistics) the current statistics after entering in all cases.
      Since:
      20.3
    • leave

      public void leave(SpecializationStatistics prev)
      Leaves the currently entered entered statistics. It is required to leave a statistics block after it was entered. It is recommended to use a finally block for this purpose.
      Since:
      20.3