Performance on Agent with Storage
Example showing how to analyze the runtime and memory usage of an Agent that is using storage.
Create a Python file
1"""Run `uv pip install openai kern-ai` to install dependencies."""23from kern.agent import Agent4from kern.db.sqlite import SqliteDb5from kern.eval.performance import PerformanceEval6from kern.models.openai import OpenAIResponses78db = SqliteDb(db_file="tmp/storage.db")91011def run_agent():12 agent = Agent(13 model=OpenAIResponses(id="gpt-5.2"),14 system_message="Be concise, reply with one sentence.",15 add_history_to_context=True,16 db=db,17 )18 response_1 = agent.run("What is the capital of France?")19 print(response_1.content)2021 response_2 = agent.run("How many people live there?")22 print(response_2.content)2324 return response_2.content252627response_with_storage_perf = PerformanceEval(28 name="Storage Performance",29 func=run_agent,30 num_iterations=1,31 warmup_runs=0,32)3334if __name__ == "__main__":35 response_with_storage_perf.run(print_results=True, print_summary=True)Set up your virtual environment
1uv venv --python 3.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateInstall dependencies
1uv pip install -U openai kern-aiExport your OpenAI API key
1export OPENAI_API_KEY="your_openai_api_key_here"1$Env:OPENAI_API_KEY="your_openai_api_key_here"Run Agent
1python performance_with_storage.py