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

Add benchmarks #34

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Make sure you have these tools installed:
- Node.js (18.0.0+)
- Poetry (1.4.0+)

Note: the project is only tested with python 3.11, and it is recommended to use the same version.

### 🔑 API keys setup

Create a `.env.development` file in the project root:
Expand Down
46 changes: 46 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,49 @@ Common HTTP Status Codes
- ``400 Bad Request``: Invalid parameters
- ``422 Unprocessable Entity``: Invalid request body
- ``500 Internal Server Error``: Server-side error


API Benchmark
-------------

The following table shows latency benchmarks for the /recommend API endpoint. Tests were run with different combinations of query parameters and reranking options. Each request was made sequentially to measure individual request latency accurately.
The summary statistics are generating from 50 runs with a timeout of 30 seconds w/ no delay between each request.

.. list-table::
:header-rows: 1

* - Test Case
- Mean (s)
- Median (s)
- Std Dev (s)
- Min (s)
- Max (s)
- Sample Size
* - Query only
- 6.686
- 5.985
- 2.336
- 4.504
- 19.362
- 48
* - Query w/ reranking
- 8.729
- 8.547
- 1.964
- 5.249
- 14.133
- 50
* - Query w/ location
- 6.795
- 6.260
- 3.560
- 3.277
- 27.860
- 46
* - Query w/ location and reranking
- 8.197
- 7.934
- 1.867
- 5.720
- 13.688
- 50
6 changes: 3 additions & 3 deletions health_rec/services/rag.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def _filter_by_location(
"""Filter services by location and radius."""
filtered_services = []
for service in services:
if service.metadata.get("Latitude") and service.metadata.get("Longitude"):
if service.metadata.get("latitude") and service.metadata.get("longitude"):
service_location = (
float(service.metadata["Latitude"]),
float(service.metadata["Longitude"]),
float(service.metadata["latitude"]),
float(service.metadata["longitude"]),
)
distance = _calculate_distance(service_location, location)
if distance <= radius:
Expand Down