package stats
import "cuelang.org/go/cue/stats"
Package stats is an experimental package for getting statistics on CUE evaluations.
Index ¶
Types ¶
type Counts ¶
type Counts struct {
// EvalVersion is the evaluator version which was used for the CUE evaluation,
// corresponding to one of the values under [cuelang.org/go/cue/cuecontext.EvalVersion].
EvalVersion internal.EvaluatorVersion
// Unifications counts the number of calls to adt.Unify
Unifications int64
// Disjuncts indicates the number of total disjuncts processed as part
// of a Unify operation. A unification with no | operator counts as a
// single disjunct, so Disjuncts is always greater than or equal to the
// number of Unifications.
//
// If Disjuncts is much larger than Unification, this may indicate room
// for optimization. In particular, most practical uses of disjunctions
// should allow for near-linear processing.
Disjuncts int64
// Notifications counts how often a Vertex is added to the notification
// queue. This is typically only the case when a Vertex is involved in
// some kind of cycle, so this should be relatively low in practice
// compared to the number of unifications.
Notifications int64 // Number of notifications sent to nodes.
// Conjuncts is an estimate of the number of conjunctions processed during
// the calls to Unify. This includes the conjuncts added in the compilation
// phase as well as the derivative conjuncts inserted from other nodes
// after following references.
//
// A number of Conjuncts much larger than Disjuncts may indicate non-linear
// algorithmic behavior.
Conjuncts int64
// Typo checking counters
NumCloseIDs int64 // Number of close IDs used
ConjunctInfos int64 // Number of conjunct infos created
MaxConjunctInfos int64 // Maximum number of conjunct infos in a node
MaxReqSets int64 // Maximum number of requirement sets
MaxRedirect int64 // Maximum number of redirects in containsDefID
// GenerationMismatch indicates the number of times a node was unified
// with a different generation than the one it was created in.
GenerationMismatch int64 // Number of exceptional unification cases
// MisalignedConjunct indicates the number of conjuncts that were dropped
// because they were not aligned with the current generation of the context.
// Generally this happens because a previously finalized vertex is unified
// in as a value, not constraint, in which case it is okay to ignore
// closedness info. If it were included as a schema, top-level conjuncts
// would be unified and mapped to a local tree.
MisalignedConjunct int64
// MisalignedConstraint indicates the number of constraints that were not
// aligned. This is more likely to be a bug.
MisalignedConstraint int64
// SkippedNotification indicates the number of notifications that were
// skipped because the value was already finalized. This may miss conjuncts
// when it occurs during evaluation, but it may also be triggered during
// dependency analysis, in which case it is benign.
SkippedNotification int64
// ResolveDep counts the number calls to markResolver in dep.go.
ResolveDep int64
Freed int64 // Number of buffers returned to the free pool.
Reused int64 // Number of times a buffer is reused instead of allocated.
Allocs int64 // Total number of allocated buffer objects.
Retained int64 // Number of times a buffer is retained upon finalization.
}
Counts holds counters for key events during a CUE evaluation.
This is an experimental type and the contents may change without notice.
func (*Counts) Add ¶
func (Counts) Leaks ¶
Leaks reports the number of nodeContext structs leaked. These are typically benign, as they will just be garbage collected, as long as the pointer from the original nodes has been eliminated or the original nodes are also not referred to. But Leaks may have notable impact on performance, and thus should be avoided.
func (Counts) Since ¶
func (Counts) String ¶
Source Files ¶
stats.go
- Version
- v0.15.1 (latest)
- Published
- Nov 21, 2025
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 4 months ago –
Tools for package owners.