Raxol.Performance.CycleProfiler.Stats (Raxol v2.6.0)

View Source

Pure functions for computing statistics from cycle profiler timing data.

Computes min, max, average, and percentile (p50, p95, p99) values from lists of timing measurements. Used by CycleProfiler to summarize update and render cycle performance.

Summary

Functions

Computes statistics for a list of numeric values (microseconds).

Computes statistics for multiple named fields extracted from a list of structs/maps.

Formats a timing_stats map into a human-readable report string.

Types

timing_stats()

@type timing_stats() :: %{
  count: non_neg_integer(),
  min: number(),
  max: number(),
  avg: float(),
  p50: number(),
  p95: number(),
  p99: number()
}

Functions

compute(values)

@spec compute([number()]) :: timing_stats() | nil

Computes statistics for a list of numeric values (microseconds).

Returns a map with count, min, max, avg, p50, p95, p99. Returns nil for an empty list.

compute_multi(entries, fields)

@spec compute_multi([map()], [atom()]) :: %{required(atom()) => timing_stats() | nil}

Computes statistics for multiple named fields extracted from a list of structs/maps.

Parameters

  • entries - List of maps/structs
  • fields - List of field keys to extract and compute stats for

Returns

Map of %{field_name => timing_stats()}.

format_report(stats, label)

@spec format_report(timing_stats() | nil, String.t()) :: String.t()

Formats a timing_stats map into a human-readable report string.