Class InstrumentingProfiler

java.lang.Object
org.gradle.profiler.Profiler
org.gradle.profiler.InstrumentingProfiler
Direct Known Subclasses:
AsyncProfiler, JfrProfiler, JProfilerProfiler, YourKitProfiler

public abstract class InstrumentingProfiler extends Profiler
A profiler that can:
  • Instrument a JVM using JVM args
  • Start recording on JVM start, using JVM args
  • Capture snapshot on JVM exit, using JVM args
  • Use some communication mechanism to start recording in an instrumented JVM that is currently running.
  • Use some communication mechanism to pause recording in an instrumented JVM that is currently running.
  • Use some communication mechanism to capture a snapshot from an instrumented JVM that is currently running.

The profiler may support starting recording multiple times for a given JVM. The implementation should indicate this by overriding canRestartRecording(ScenarioSettings).

  • Constructor Details

    • InstrumentingProfiler

      public InstrumentingProfiler()
  • Method Details

    • newJvmArgsCalculator

      public JvmArgsCalculator newJvmArgsCalculator(ScenarioSettings settings)
      Calculates the JVM args for all builds, including warm-ups.

      When the daemon will not be reused, this does nothing as there is no need to instrument the warm-up builds in this case.

      When the daemon will be reused for all builds, then instrument the daemon but do not start recording or capture snapshots yet. Recording and capture will be enabled later when the measured builds run.

      Overrides:
      newJvmArgsCalculator in class Profiler
    • newInstrumentedBuildsJvmArgsCalculator

      public JvmArgsCalculator newInstrumentedBuildsJvmArgsCalculator(ScenarioSettings settings)
      Calculates the JVM args for measured builds.

      When the daemon will be reused for all builds, this does nothing as the daemon is already instrumented (above).

      When using a cold daemon, start the JVM with recording enabled but do not capture snapshots yet.

      When using no daemon, start the JVM with recording enabled and capture a snapshot when the JVM exits.

      Overrides:
      newInstrumentedBuildsJvmArgsCalculator in class Profiler
    • newController

      public ProfilerController newController(String pid, ScenarioSettings settings)
      Creates a controller for this profiler.

      When the daemon will be reused for all builds, create a controller that starts and stops recording when requested, and that captures a snapshot at the end of the session.

      When using a cold daemon, create a controller that stops recording and captures a snapshot when requested, but does not start recording as this is already enabled when the JVM starts.

      When using no daemon, return a controller that finishes the session only, as recording and snapshot capture are already enabled when the JVM starts.

      Overrides:
      newController in class Profiler
    • validate

      public void validate(ScenarioSettings settings, Consumer<String> reporter)
      Overrides:
      validate in class Profiler
    • validateMultipleIterationsWithCleanupAction

      protected void validateMultipleIterationsWithCleanupAction(ScenarioSettings settings, Consumer<String> reporter)
    • validateMultipleDaemons

      protected void validateMultipleDaemons(ScenarioSettings settings, Consumer<String> reporter)
    • canRestartRecording

      protected boolean canRestartRecording(ScenarioSettings settings)
      Can this profiler implementation restart recording, for the same JVM?
    • jvmArgsWithInstrumentation

      protected abstract JvmArgsCalculator jvmArgsWithInstrumentation(ScenarioSettings settings, boolean startRecordingOnProcessStart, boolean captureSnapshotOnProcessExit)
      Creates JVM args to instrument that JVM with the given capabilities enabled.
    • doNewController

      protected abstract InstrumentingProfiler.SnapshotCapturingProfilerController doNewController(ScenarioSettings settings)