Class CompilationProfiler

java.lang.Object
io.micronaut.python.compiler.CompilationProfiler

@Internal public final class CompilationProfiler extends Object
Collects the CompilationProfile of one compilation: phases are timed inclusively from phase(String) to the close of the span it returns, counters accumulate, and the output directory is inventoried once the compilation wrote it. Nothing here runs unless profiling was enabled on the compiler; a null profiler is a no-op at every call site through the static span(CompilationProfiler, String) and increment(CompilationProfiler, String, long).

The profiler is used from one thread at a time (the compiler runs javac on the calling thread), but the methods synchronise anyway so a callback from another thread cannot corrupt it.

Since:
5.3.0
  • Constructor Details

    • CompilationProfiler

      public CompilationProfiler()
      Creates a profiler recording the JVM, its process and its uptime, which tells a compilation in a fresh worker from one in a reused, warmed-up worker.
  • Method Details

    • span

      Starts a phase on the given profiler, or nothing when it is null.
      Parameters:
      profiler - The profiler, or null when profiling is off
      name - The phase name
      Returns:
      The span to close when the phase ends
    • increment

      public static void increment(@Nullable @Nullable CompilationProfiler profiler, String name, long delta)
      Adds to a counter of the given profiler, or nothing when it is null.
      Parameters:
      profiler - The profiler, or null when profiling is off
      name - The counter name
      delta - The amount to add
    • attribute

      public void attribute(String name, String value)
      Records an attribute of the compilation.
      Parameters:
      name - The name
      value - The value
    • phase

      public CompilationProfiler.Span phase(String name)
      Starts a phase. A phase started again accumulates; a phase started while another runs is nested in it for the report.
      Parameters:
      name - The phase name
      Returns:
      The span to close when the phase ends
    • count

      public void count(String name, long delta)
      Adds to a counter.
      Parameters:
      name - The counter name
      delta - The amount to add
    • inventory

      public void inventory(Path outputDirectory)
      Inventories the output directory: the generated Java sources, class files, Python sources and bytecode, and the other resources, with their sizes.
      Parameters:
      outputDirectory - The output directory of the compilation
    • finish

      public CompilationProfile finish()
      Ends the profile.
      Returns:
      The profile