Skip to content

Commit

Permalink
Merge pull request #34 from VectorInstitute/benchmark_api
Browse files Browse the repository at this point in the history
Add benchmarks
  • Loading branch information
amrit110 authored Nov 28, 2024
2 parents 8715fc1 + f67213a commit a42b657
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
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

0 comments on commit a42b657

Please sign in to comment.