MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / TimeRecorder

Class TimeRecorder

demo/Paper2Poster/docling/utils/profiling.py:39–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37
38
39class TimeRecorder:
40 def __init__(
41 self,
42 conv_res: "ConversionResult",
43 key: str,
44 scope: ProfilingScope = ProfilingScope.PAGE,
45 ):
46 if settings.debug.profile_pipeline_timings:
47 if key not in conv_res.timings.keys():
48 conv_res.timings[key] = ProfilingItem(scope=scope)
49 self.conv_res = conv_res
50 self.key = key
51
52 def __enter__(self):
53 if settings.debug.profile_pipeline_timings:
54 self.start = time.monotonic()
55 self.conv_res.timings[self.key].start_timestamps.append(datetime.utcnow())
56 return self
57
58 def __exit__(self, *args):
59 if settings.debug.profile_pipeline_timings:
60 elapsed = time.monotonic() - self.start
61 self.conv_res.timings[self.key].times.append(elapsed)
62 self.conv_res.timings[self.key].count += 1

Callers 15

__call__Method · 0.90
__call__Method · 0.90
__call__Method · 0.90
__call__Method · 0.90
__call__Method · 0.90
__call__Method · 0.90
__call__Method · 0.90
__call__Method · 0.90
__call__Method · 0.90
__call__Method · 0.90
executeMethod · 0.90
_enrich_documentMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected