Staging instance, all changes can be removed at any time

Skip to content

statsd: Add timed_iter() method

vlorentz requested to merge timed_iter into master

It allows measuring the time spent in iter() and next(). This is useful when we want to measure independently the time spent in a for loop when the iteration itself is resource_heavy. For example:

it = stream_results(
    storage.snapshot_get_branches,  # does network calls
    snapshot_id,
)

it = statsd.timed_iter("get_branches_total_seconds", it)

for value in it:
    with statsd.timed("worker_total_seconds"):
        worker(value)

Will be used to debug swh/meta#5035 (closed) to measure the time spent in stream_results(self.scheduler.get_listed_origins, url=origin["url"])

Merge request reports

Loading