Package com.helix.profiler.node
Class NodeStats
java.lang.Object
com.helix.profiler.node.NodeStats
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.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleCalculates the mean execution cost in nanoseconds.doubleCalculates the cost-to-failure ratio: C_i / F_i.longlongdoubleCalculates the failure / short-circuit probability.longvoidrecord(long elapsedNanos, boolean result) Records a single node execution.voidreset()Resets all internal counters to zero.snapshot()Creates an immutable point-in-time snapshot of this node's telemetry.toString()
-
Constructor Details
-
NodeStats
-
-
Method Details
-
record
public void record(long elapsedNanos, boolean result) Records a single node execution.- Parameters:
elapsedNanos- elapsed duration in nanosecondsresult- evaluation outcome (false represents failure/short-circuit)
-
getRuleName
-
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
Creates an immutable point-in-time snapshot of this node's telemetry.- Returns:
- immutable snapshot
-
toString
-