Skip to main content

profile

One session with one named capture, scoped to a with block.

The capture ends when the block exits; the session stays readable on the returned object, so exports and summaries run after the block::

with crt.profiler.profile("step") as prof:
run_model()
prof.save("profile_out")

__init__

__init__(self, name: 'str' = 'default') -> 'None'

Initialize self. See help(type(self)) for accurate signature.

add_marker

add_marker(self, label: 'str') -> 'None'

Drop a named instant event at this point; the capture must be active (inside the with block).

export_chrome_trace

export_chrome_trace(self, path: 'PathLike') -> 'None'

Write the Chrome-tracing timeline JSON to path (open it in chrome://tracing or Perfetto).

save

save(self, dir: 'PathLike') -> 'None'

Write the standard set into dir (created if missing): chrome_trace.json, report.json, memory_stats.json, summary.txt.

summary

summary(self) -> 'str'

The per-op text summary of everything captured so far.