Skip to main content
PerformanceEval measures the run time and peak memory usage of a function, with warm-up runs excluded from the final statistics.
from agno.eval import PerformanceEval, PerformanceResult

Parameters

ParameterTypeDefaultDescription
funcCallableRequiredFunction to measure. Must be async when using arun().
measure_runtimeboolTrueMeasure execution time per iteration.
measure_memoryboolTrueMeasure peak memory usage per iteration with tracemalloc, adjusted against a computed baseline.
nameOptional[str]NoneEvaluation name.
eval_idstrAutogenerated UUIDEvaluation ID.
warmup_runsOptional[int]10Number of unmeasured runs before measurement starts.
num_iterationsint50Number of measured iterations. Runtime and memory are measured in separate passes of this many iterations each.
print_summaryboolFalsePrint the statistics summary table after the run.
print_resultsboolFalsePrint the per-iteration results table after the run.
show_spinnerboolTrueRender the progress spinner. Set to False when the eval runs inside code that must not write to the console.
memory_growth_trackingboolFalseCompare memory snapshots between iterations and log growth sources. Requires debug_mode for the log output.
top_n_memory_allocationsint5Number of memory allocation sources logged when tracking growth.
agent_idOptional[str]NoneAgent ID attached to the stored eval run.
team_idOptional[str]NoneTeam ID attached to the stored eval run.
model_idOptional[str]NoneModel ID attached to the stored eval run.
model_providerOptional[str]NoneModel provider attached to the stored eval run.
file_path_to_save_resultsOptional[str]NoneFile path where the result is saved.
debug_modeboolFalseEnable debug logs, including raw and adjusted memory readings. Defaults to True when the AGNO_DEBUG environment variable is "true".
dbOptional[Union[BaseDb, AsyncBaseDb]]NoneDatabase where the eval run is stored.
telemetryboolTrueLog minimal telemetry for the eval run.
resultOptional[PerformanceResult]NoneResult of the evaluation. Set after a run completes.

Methods

MethodReturn typeDescription
run(*, print_summary=False, print_results=False, memory_growth_tracking=False)PerformanceResultRun warm-ups, then measure runtime and memory over num_iterations. Raises with an async database; use arun() instead.
arun(*, print_summary=False, print_results=False, memory_growth_tracking=False)PerformanceResultAsync version of run(). Raises when func is not a coroutine function.

PerformanceResult

Runtime statistics are in seconds; memory statistics are in MiB. All statistics are 0 when the corresponding measurement is disabled.
FieldTypeDescription
run_timesList[float]Measured run time per iteration.
avg_run_timefloatAverage run time.
min_run_timefloatFastest run time.
max_run_timefloatSlowest run time.
std_dev_run_timefloatStandard deviation of run times.
median_run_timefloatMedian run time.
p95_run_timefloat95th percentile run time.
memory_usagesList[float]Baseline-adjusted peak memory usage per iteration.
avg_memory_usagefloatAverage memory usage.
min_memory_usagefloatLowest memory usage.
max_memory_usagefloatHighest memory usage.
std_dev_memory_usagefloatStandard deviation of memory usage.
median_memory_usagefloatMedian memory usage.
p95_memory_usagefloat95th percentile memory usage.
PerformanceResult also exposes print_summary() and print_results(), both accepting console, measure_memory, and measure_runtime arguments.