Class TimingCollector

java.lang.Object
dev.metaschema.core.model.constraint.TimingCollector
All Implemented Interfaces:
ValidationEventListener

public class TimingCollector extends Object implements ValidationEventListener
A ValidationEventListener implementation that collects timing measurements for all validation events.

Timing data is organized hierarchically:

This class is thread-safe. Each thread maintains its own stack of start times to handle nested events correctly (e.g., a constraint evaluation that triggers let-statement evaluations).

See Also:
  • Constructor Details

    • TimingCollector

      public TimingCollector()
      Construct a new, empty timing collector.
  • Method Details

    • beforeValidation

      public void beforeValidation(@NonNull URI document)
      Description copied from interface: ValidationEventListener
      Called before validation of a document begins.
      Specified by:
      beforeValidation in interface ValidationEventListener
      Parameters:
      document - the URI of the document being validated
    • afterValidation

      public void afterValidation(@NonNull URI document)
      Description copied from interface: ValidationEventListener
      Called after validation of a document completes.
      Specified by:
      afterValidation in interface ValidationEventListener
      Parameters:
      document - the URI of the document that was validated
    • beforePhase

      public void beforePhase(@NonNull ValidationPhase phase)
      Description copied from interface: ValidationEventListener
      Called before a validation phase begins.
      Specified by:
      beforePhase in interface ValidationEventListener
      Parameters:
      phase - the phase about to start
    • afterPhase

      public void afterPhase(@NonNull ValidationPhase phase)
      Description copied from interface: ValidationEventListener
      Called after a validation phase completes.
      Specified by:
      afterPhase in interface ValidationEventListener
      Parameters:
      phase - the phase that completed
    • beforeConstraintEvaluation

      public void beforeConstraintEvaluation(@NonNull IConstraint constraint, @NonNull INodeItem target)
      Description copied from interface: ValidationEventListener
      Called before a single constraint is evaluated against a target node.
      Specified by:
      beforeConstraintEvaluation in interface ValidationEventListener
      Parameters:
      constraint - the constraint being evaluated
      target - the node item the constraint is evaluated against
    • afterConstraintEvaluation

      public void afterConstraintEvaluation(@NonNull IConstraint constraint, @NonNull INodeItem target)
      Description copied from interface: ValidationEventListener
      Called after a single constraint evaluation completes.
      Specified by:
      afterConstraintEvaluation in interface ValidationEventListener
      Parameters:
      constraint - the constraint that was evaluated
      target - the node item the constraint was evaluated against
    • beforeLetEvaluation

      public void beforeLetEvaluation(@NonNull ILet let)
      Description copied from interface: ValidationEventListener
      Called before a let-statement variable binding is evaluated.
      Specified by:
      beforeLetEvaluation in interface ValidationEventListener
      Parameters:
      let - the let expression being evaluated
    • afterLetEvaluation

      public void afterLetEvaluation(@NonNull ILet let)
      Description copied from interface: ValidationEventListener
      Called after a let-statement variable binding evaluation completes.
      Specified by:
      afterLetEvaluation in interface ValidationEventListener
      Parameters:
      let - the let expression that was evaluated
    • getPhaseTiming

      @Nullable public TimingRecord getPhaseTiming(@NonNull ValidationPhase phase)
      Get the timing record for a specific validation phase.
      Parameters:
      phase - the phase to look up
      Returns:
      the timing record, or null if the phase was not recorded
    • getPhaseTimings

      @NonNull public Map<ValidationPhase,TimingRecord> getPhaseTimings()
      Get all phase timing records.
      Returns:
      an unmodifiable map of phase to timing record
    • getConstraintTiming

      @Nullable public TimingRecord getConstraintTiming(@NonNull String constraintId)
      Get the timing record for a specific constraint by its internal identifier.
      Parameters:
      constraintId - the constraint's internal identifier
      Returns:
      the timing record, or null if the constraint was not recorded
    • getConstraintTimings

      @NonNull public Map<String,TimingRecord> getConstraintTimings()
      Get all constraint timing records.
      Returns:
      an unmodifiable map of constraint identifier to timing record
    • getLetTiming

      @Nullable public TimingRecord getLetTiming(@NonNull ILet let)
      Get the timing record for a specific let-statement.
      Parameters:
      let - the let-statement to look up
      Returns:
      the timing record, or null if the let was not recorded
    • getLetTimings

      @NonNull public Map<ILet,TimingRecord> getLetTimings()
      Get all let-statement timing records.
      Returns:
      an unmodifiable map of let-statement to timing record
    • getValidationTiming

      @Nullable public TimingRecord getValidationTiming()
      Get the overall validation timing record.
      Returns:
      the validation timing record, or null if validation was not recorded