Timing Vespa queries
Disconsidering network and other non-search related costs
When comparing different query models, we might want to compute the time difference between them. Doing that from the outside is tricky because it is hard to separate network and other non-search related costs out of the final numbers.
Luckily we can accomplish this by setting presentation.timing
equal to true
in the request body. Without relying on pyvespa
API, we can add the keyword parameter presentation.timing
in the app.query
call.
from vespa.application import Vespa
from vespa.query import Query, RankProfile, OR
app = Vespa(url = "https://api.cord19.vespa.ai")
result = app.query(
query="what is covid?",
query_model=Query(
match_phase=OR(),
rank_profile=RankProfile(name="bm25")
),
**{"presentation.timing": "true"}
)
result.json['timing']
Such a useful feature could be part of the pyvespa
API:
result = app.query(
query="what is covid?",
query_model=Query(
match_phase=OR(),
rank_profile=RankProfile(name="bm25")
),
timing=True
)