Class NodeStats

java.lang.Object
com.helix.profiler.node.NodeStats

public class NodeStats extends Object
Thread-safe statistics tracker for an individual AST expression node.

Tracks total execution count, cumulative execution duration in nanoseconds, and failure/short-circuit count using high-throughput striped LongAdder counters to ensure zero lock contention in highly concurrent execution paths.

  • Constructor Details

    • NodeStats

      public NodeStats(String ruleName, String nodeId)
  • Method Details

    • record

      public void record(long elapsedNanos, boolean result)
      Records a single node execution.
      Parameters:
      elapsedNanos - elapsed duration in nanoseconds
      result - evaluation outcome (false represents failure/short-circuit)
    • getRuleName

      public String getRuleName()
    • getNodeId

      public String getNodeId()
    • getExecutionCount

      public long getExecutionCount()
    • getTotalDurationNanos

      public long getTotalDurationNanos()
    • getFailureCount

      public long getFailureCount()
    • getAverageCostNanos

      public double getAverageCostNanos()
      Calculates the mean execution cost in nanoseconds.
      Returns:
      average cost in nanoseconds, or 0.0 if never executed
    • getFailureRate

      public double getFailureRate()
      Calculates the failure / short-circuit probability.
      Returns:
      failure rate in [0.0, 1.0], or 0.0 if never executed
    • getCostToFailureRatio

      public double getCostToFailureRatio()
      Calculates the cost-to-failure ratio: C_i / F_i.

      Used by adaptive AST optimizers to sort boolean predicate chains such that nodes with the lowest ratio (cheapest to fail) are evaluated first.

      Returns:
      cost-to-failure ratio, or POSITIVE_INFINITY if failure rate is zero
    • reset

      public void reset()
      Resets all internal counters to zero.
    • snapshot

      public NodeStats.Snapshot snapshot()
      Creates an immutable point-in-time snapshot of this node's telemetry.
      Returns:
      immutable snapshot
    • toString

      public String toString()
      Overrides:
      toString in class Object