Session
Collect one source profiling run and render portable HTML.
| Parameters |
config : Config | None, default=None Prevalidated configuration. Mutually exclusive with keyword options. Explicit Config fields overriding project settings. |
| Attributes |
config : Config Validated options retained for this profiling session.
result : ProfileResult Complete normalized result containing captured source, the run tree,
measurements, capabilities, and diagnostics. Finalized by
state : SessionState Lifecycle state; a session starts once and remains stopped. |
See Also
Example
>>> from linescope import Session
>>> with Session(
... backend="trace", display="none", notebooks=False, spark=False
... ) as session:
... value = sum(range(10))
>>> value
45
>>> str(session.state)
'stopped'
Methods
start |
Begin collection and install configured notebook and Spark observers. |
stop |
Finalize measurements and restore instrumentation. |
html |
Return the complete self-contained report as HTML. |
save |
Write an HTML snapshot without opening a browser. |
show |
Open a browser report or display it inside a notebook cell. |
Begin collection and install configured notebook and Spark observers.
| Returns |
This running session. |
Finalize measurements and restore instrumentation.
Display the completed report when configured and retain the complete
result on session.result. Return None so notebook cells add no
result representation. Repeated calls do nothing without redisplay.
The completed result remains accessible if report display fails.
Return the complete self-contained report as HTML.
| Returns |
str Report containing the captured source and current measurements. |
Write an HTML snapshot without opening a browser.
| Parameters |
path : str | Path Destination filename. Missing parent directories are created. |
| Returns |
Absolute path to the saved report. |
Open a browser report or display it inside a notebook cell.
Return None so notebook cells display only the report. Use html()
to retrieve the self-contained HTML without displaying it.
Detect notebook kernels for automatic inline display. Scripts and terminal IPython open a browser.