instantiate_agent.py
Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Run the example
Save the code above as
instantiate_agent.py, then run:Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Measure runtime and memory of 1000 bare Agno Agent constructions with only a system message.
"""
Agent Instantiation Performance Evaluation
==========================================
Demonstrates measuring agent instantiation performance.
"""
from agno.agent import Agent
from agno.eval.performance import PerformanceEval
# ---------------------------------------------------------------------------
# Create Benchmark Function
# ---------------------------------------------------------------------------
def instantiate_agent():
return Agent(system_message="Be concise, reply with one sentence.")
# ---------------------------------------------------------------------------
# Create Evaluation
# ---------------------------------------------------------------------------
instantiation_perf = PerformanceEval(
name="Instantiation Performance", func=instantiate_agent, num_iterations=1000
)
# ---------------------------------------------------------------------------
# Run Evaluation
# ---------------------------------------------------------------------------
if __name__ == "__main__":
instantiation_perf.run(print_results=True, print_summary=True)
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Install dependencies
uv pip install -U agno memory-profiler
Run the example
instantiate_agent.py, then run:python instantiate_agent.py
Was this page helpful?