Lightweight ETS-backed counters/samplers for proof-session debugging, plus user-facing helpers to compile and pretty-print a snapshot.
Operates on the :stats table created by EtsKeeper. All ops are
concurrency-safe and lock-free; samplers and max-trackers use CAS via
:ets.select_replace/2.
Schema: {key, integer} # counters & max trackers {key, count, sum, min, max} # samplers {key, term} # one-off set/get (e.g. timestamps)
Summary
Functions
Compiles a raw snapshot into a structured report grouped by category:
:timing, :search, :rules, :branches, :csp.
Total proof duration in microseconds, or nil if timing data is missing.
Pretty-prints stats as a human-readable string. Accepts either a raw snapshot or a compiled report.
Atomic increment-or-create.
Best-effort max tracker. Retries on contention up to retries times.
Records a sample. Maintains {count, sum, min, max} for the key.
One-shot set (non-atomic, used for timestamps / metadata).
Snapshot the entire table as a map. Samplers expand to a stats map.
Types
@type sampler() :: %{ count: non_neg_integer(), sum: number(), min: number(), max: number(), avg: number() }
@type tables() :: %{stats: :ets.table()} | :ets.table()
Functions
Compiles a raw snapshot into a structured report grouped by category:
:timing, :search, :rules, :branches, :csp.
Derived metrics included:
timing.duration_us/duration_msfrom the start/finish timestamps.search.steps_per_secfromsteps_totalandduration_us.csp.success_ratefromcsp_calls_succeeded / csp_calls.
Idempotent: a compiled report passed in is returned unchanged.
@spec duration_us(snapshot()) :: non_neg_integer() | nil
Total proof duration in microseconds, or nil if timing data is missing.
Pretty-prints stats as a human-readable string. Accepts either a raw snapshot or a compiled report.
Options:
:verbose(defaultfalse) — include rule/branch counters whose value is zero. By default they are hidden to reduce noise.:sections(default:all) — subset of[:timing, :search, :rules, :branches, :csp]to render, in the given order.
Atomic increment-or-create.
@spec record_max(tables(), atom(), integer(), non_neg_integer()) :: :ok
Best-effort max tracker. Retries on contention up to retries times.
@spec record_sample(tables(), atom(), number(), non_neg_integer()) :: :ok
Records a sample. Maintains {count, sum, min, max} for the key.
One-shot set (non-atomic, used for timestamps / metadata).
Snapshot the entire table as a map. Samplers expand to a stats map.