-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Add performance benchmarks for database initialization and app…
… startup (#4367) * feat: add benchmark markers to multiple test cases * test: add performance tests for database initialization and app startup Introduce benchmark tests to measure the performance of database initialization and application startup. This helps ensure efficiency and identify potential bottlenecks in the setup process. * feat: update CodSpeed workflow to enhance test execution and duration tracking * refactor: streamline performance tests for database initialization and app startup * test: enhance app startup performance test with pytest benchmarking * test: update benchmark for database initialization Remove unnecessary benchmark call and simplify the database initialization test to enhance clarity and reliability in performance testing. * chore: remove unnecessary pytest options from CodSpeed workflow * Add environment setup for test_app_startup benchmark test * Add benchmark test for app startup with database setup and flow loading * Add benchmark markers to flow building tests in test_chat_endpoint.py * perf: add benchmarks for service initialization and caching Introduce benchmarks for various service initialization functions and LLM caching to improve performance evaluations. * Remove unused benchmark marker from test function in test_chat_endpoint.py * perf: initialize services in super user benchmark test * Add benchmarking to test_create_starter_projects in performance tests * Add asyncio threading to benchmark tests and remove benchmark fixture usage * Remove database initialization benchmark test from performance suite
- Loading branch information
1 parent
5a4d4c8
commit cd3a747
Showing
5 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import asyncio | ||
|
||
import pytest | ||
from langflow.services.deps import get_settings_service | ||
|
||
|
||
@pytest.mark.benchmark | ||
async def test_initialize_services(): | ||
"""Benchmark the initialization of services.""" | ||
from langflow.services.utils import initialize_services | ||
|
||
await asyncio.to_thread(initialize_services, fix_migration=False) | ||
|
||
|
||
@pytest.mark.benchmark | ||
async def test_setup_llm_caching(): | ||
"""Benchmark LLM caching setup.""" | ||
from langflow.interface.utils import setup_llm_caching | ||
|
||
await asyncio.to_thread(setup_llm_caching) | ||
|
||
|
||
@pytest.mark.benchmark | ||
async def test_initialize_super_user(): | ||
"""Benchmark super user initialization.""" | ||
from langflow.initial_setup.setup import initialize_super_user_if_needed | ||
from langflow.services.utils import initialize_services | ||
|
||
await asyncio.to_thread(initialize_services, fix_migration=False) | ||
await asyncio.to_thread(initialize_super_user_if_needed) | ||
|
||
|
||
@pytest.mark.benchmark | ||
async def test_get_and_cache_all_types_dict(): | ||
"""Benchmark get_and_cache_all_types_dict function.""" | ||
from langflow.interface.types import get_and_cache_all_types_dict | ||
|
||
settings_service = await asyncio.to_thread(get_settings_service) | ||
result = await asyncio.to_thread(get_and_cache_all_types_dict, settings_service) | ||
assert result is not None | ||
|
||
|
||
@pytest.mark.benchmark | ||
async def test_create_starter_projects(): | ||
"""Benchmark creation of starter projects.""" | ||
from langflow.initial_setup.setup import create_or_update_starter_projects | ||
from langflow.interface.types import get_and_cache_all_types_dict | ||
from langflow.services.utils import initialize_services | ||
|
||
await asyncio.to_thread(initialize_services, fix_migration=False) | ||
settings_service = await asyncio.to_thread(get_settings_service) | ||
types_dict = await get_and_cache_all_types_dict(settings_service) | ||
await asyncio.to_thread(create_or_update_starter_projects, types_dict) | ||
|
||
|
||
@pytest.mark.benchmark | ||
async def test_load_flows(): | ||
"""Benchmark loading flows from directory.""" | ||
from langflow.initial_setup.setup import load_flows_from_directory | ||
|
||
await asyncio.to_thread(load_flows_from_directory) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters