mirror of
https://github.com/hwchase17/langchain.git
synced 2026-04-10 14:33:45 +00:00
perf(langchain): add benchmark command (#36641)
add benchmark in Makefile
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
.PHONY: all start_services stop_services coverage coverage_agents test test_fast extended_tests test_watch test_watch_extended integration_tests check_imports check_version lint format type lint_diff format_diff lint_package lint_tests help
|
||||
.PHONY: all start_services stop_services coverage coverage_agents test test_fast benchmark extended_tests test_watch test_watch_extended integration_tests check_imports check_version lint format type lint_diff format_diff lint_package lint_tests help
|
||||
|
||||
# Default target executed when no arguments are given to make.
|
||||
all: help
|
||||
@@ -46,6 +46,9 @@ test:
|
||||
test_fast:
|
||||
LANGGRAPH_TEST_FAST=1 uv run --group test pytest -n auto $(PYTEST_EXTRA) --disable-socket --allow-unix-socket $(TEST_FILE)
|
||||
|
||||
benchmark:
|
||||
uv run --group test pytest tests/benchmarks/test_create_agent.py -m benchmark
|
||||
|
||||
extended_tests:
|
||||
make start_services && LANGGRAPH_TEST_FAST=0 uv run --group test pytest --disable-socket --allow-unix-socket --only-extended tests/unit_tests; \
|
||||
EXIT_CODE=$$?; \
|
||||
@@ -117,6 +120,7 @@ help:
|
||||
@echo 'coverage_agents - run middleware and agent tests with coverage report'
|
||||
@echo 'test - run unit tests with all services'
|
||||
@echo 'test_fast - run unit tests with in-memory services only'
|
||||
@echo 'benchmark - run the create_agent benchmark quickly'
|
||||
@echo 'tests - run unit tests (alias for "make test")'
|
||||
@echo 'test TEST_FILE=<test_file> - run all tests in file'
|
||||
@echo 'extended_tests - run only extended unit tests'
|
||||
|
||||
@@ -68,6 +68,7 @@ test = [
|
||||
"pytest-socket>=0.6.0,<1.0.0",
|
||||
"pytest-xdist<4.0.0,>=3.6.1",
|
||||
"pytest-mock",
|
||||
"pytest-benchmark>=5.1.0,<6.0.0",
|
||||
"syrupy>=4.0.2,<6.0.0",
|
||||
"toml>=0.10.2,<1.0.0",
|
||||
"blockbuster>=1.5.26,<1.6.0",
|
||||
@@ -189,6 +190,7 @@ markers = [
|
||||
"requires: mark tests as requiring a specific library",
|
||||
"scheduled: mark tests to run in scheduled testing",
|
||||
"compile: mark placeholder test used to compile integration tests without running them",
|
||||
"benchmark: mark benchmark tests",
|
||||
]
|
||||
asyncio_mode = "auto"
|
||||
filterwarnings = [
|
||||
|
||||
0
libs/langchain_v1/tests/benchmarks/__init__.py
Normal file
0
libs/langchain_v1/tests/benchmarks/__init__.py
Normal file
14
libs/langchain_v1/tests/benchmarks/test_create_agent.py
Normal file
14
libs/langchain_v1/tests/benchmarks/test_create_agent.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import pytest
|
||||
from langchain_core.language_models.fake_chat_models import GenericFakeChatModel
|
||||
from langchain_core.messages import AIMessage
|
||||
from pytest_benchmark.fixture import BenchmarkFixture
|
||||
|
||||
from langchain.agents import create_agent
|
||||
|
||||
|
||||
@pytest.mark.benchmark
|
||||
def test_create_agent_instantiation(benchmark: BenchmarkFixture) -> None:
|
||||
def instantiate_agent() -> None:
|
||||
create_agent(model=GenericFakeChatModel(messages=iter([AIMessage(content="ok")])))
|
||||
|
||||
benchmark(instantiate_agent)
|
||||
2
libs/langchain_v1/uv.lock
generated
2
libs/langchain_v1/uv.lock
generated
@@ -1986,6 +1986,7 @@ test = [
|
||||
{ name = "langchain-tests" },
|
||||
{ name = "pytest" },
|
||||
{ name = "pytest-asyncio" },
|
||||
{ name = "pytest-benchmark" },
|
||||
{ name = "pytest-cov" },
|
||||
{ name = "pytest-mock" },
|
||||
{ name = "pytest-socket" },
|
||||
@@ -2040,6 +2041,7 @@ test = [
|
||||
{ name = "langchain-tests", editable = "../standard-tests" },
|
||||
{ name = "pytest", specifier = ">=8.0.0,<10.0.0" },
|
||||
{ name = "pytest-asyncio", specifier = ">=0.23.2,<2.0.0" },
|
||||
{ name = "pytest-benchmark", specifier = ">=5.1.0,<6.0.0" },
|
||||
{ name = "pytest-cov", specifier = ">=4.0.0,<8.0.0" },
|
||||
{ name = "pytest-mock" },
|
||||
{ name = "pytest-socket", specifier = ">=0.6.0,<1.0.0" },
|
||||
|
||||
Reference in New Issue
Block a user