AgentForge.ExecutionStats (AgentForge v0.2.2)
View SourceProvides functionality for collecting and analyzing execution statistics of flows. Tracks metrics such as execution time, steps taken, and signal patterns.
Summary
Functions
Finalizes the execution stats with the result and calculates elapsed time.
Formats the execution stats into a human-readable report.
Creates a new execution stats struct with initial values.
Records a step in the execution process, updating relevant statistics.
Types
@type t() :: %AgentForge.ExecutionStats{ complete: boolean(), elapsed_ms: integer() | nil, handler_calls: %{required(atom()) => non_neg_integer()}, max_state_size: non_neg_integer(), result: any(), signal_types: %{required(atom()) => non_neg_integer()}, start_time: integer(), steps: non_neg_integer() }
Functions
Finalizes the execution stats with the result and calculates elapsed time.
Parameters
stats
- Current execution stats structresult
- The final result of the flow execution
Examples
iex> stats = AgentForge.ExecutionStats.new()
iex> final = AgentForge.ExecutionStats.finalize(stats, {:ok, "success"})
iex> final.complete and is_integer(final.elapsed_ms) and final.result == {:ok, "success"}
true
Formats the execution stats into a human-readable report.
Examples
iex> stats = AgentForge.ExecutionStats.new()
iex> stats = AgentForge.ExecutionStats.finalize(stats, {:ok, "success"})
iex> report = AgentForge.ExecutionStats.format_report(stats)
iex> String.contains?(report, "Total Steps: 0") and String.contains?(report, "Result: {:ok, \"success\"}")
true
Creates a new execution stats struct with initial values.
Examples
iex> stats = AgentForge.ExecutionStats.new()
iex> is_integer(stats.start_time) and stats.steps == 0
true
Records a step in the execution process, updating relevant statistics.
Parameters
stats
- Current execution stats structhandler_info
- Information about the handler being executedsignal
- The signal being processedstate
- Current state of the flow
Examples
iex> stats = AgentForge.ExecutionStats.new()
iex> signal = %{type: :test, data: "data"}
iex> updated = AgentForge.ExecutionStats.record_step(stats, :test_handler, signal, %{})
iex> updated.steps == 1 and updated.signal_types == %{test: 1}
true