perf: extract the timing of a section in a context manager
This makes it easier to reuse it in other (future) part of the code that
requires their own time management.
public attribute not declared in interfaces: badpeer.badattributepublic attribute not declared in interfaces: badpeer.badmethod