Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Fix performance tests for search #534

Open
Tracked by #542
rmusser01 opened this issue Feb 7, 2025 · 0 comments
Open
Tracked by #542

Bug: Fix performance tests for search #534

rmusser01 opened this issue Feb 7, 2025 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@rmusser01
Copy link
Owner

rmusser01 commented Feb 7, 2025

Issue is that it now scales out per record. Static searching is still as fast as it was, but the timings need to be updated to reflect changes to the DB handling.

#@pytest.mark.parametrize("num_records", [10, 100, 1000, 10000])
# def test_search_performance(db, num_records):
#     # Get a connection from the database
#     with db.get_connection() as conn:
#         # Populate the database with test records
#         for i in range(num_records):
#             url = f'https://example.com/perf_test_{i}'
#             info_dict = {'title': f'Performance Test Video {i}', 'uploader': 'Test Uploader'}
#             # Pass the connection explicitly
#             add_media_to_database(url, info_dict, [], 'Test summary', ['performance'],
#                                   'Test prompt', 'whisper-1', overwrite=True, db=db)
#
#         # Perform the search
#         start_time = time.time()
#         # Pass the connection explicitly to the search function
#         results = search_media_database('Performance Test', connection=conn)
#         end_time = time.time()
#
#         # Check results
#         assert len(results) == num_records
#
#         # Adjust performance expectations based on number of records
#         if num_records <= 10:
#             max_time = 0.1
#         elif num_records <= 100:
#             max_time = 0.5
#         else:
#             max_time = 2.0
#
#         search_time = end_time - start_time
#         print(f"Search time for {num_records} records: {search_time:.4f} seconds")
#         assert search_time < max_time, f"Search took {search_time:.4f} seconds, which is more than the expected {max_time} seconds for {num_records} records"
#
#         # Clean up the database after the test
#         conn.execute("DELETE FROM Media")
#         conn.execute("DELETE FROM MediaKeywords")
#         conn.execute("DELETE FROM Keywords")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant