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.
ERROR: FIXME: This is a known failure of filelog.size for data starting with \1\nOK.