You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/gpu_tracker/sub_tracker.py
+37-5Lines changed: 37 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -2,22 +2,25 @@
2
2
importinspect
3
3
importos
4
4
importtime
5
+
importfunctools
5
6
from ._helper_classesimport_TrackingFile, _SubTrackerLog
6
7
7
8
8
9
classSubTracker:
9
10
"""
10
11
Context manager that logs to a file for the purposes of sub tracking a code block using the timestamps at which the codeblock begins and ends.
11
12
Entering the context manager marks the beginning of the code block and exiting the context manager marks the end of the code block.
12
-
At the beginning of the codeblock, the ``SubTracker`` logs a row to a tablular file (".csv" or ".sqlite") that includes the timestamp along with a name for the code block and an indication of whether it is the start or end of the code bock.
13
+
At the beginning of the codeblock, the ``SubTracker`` logs a row to a tabular file (".csv" or ".sqlite") that includes the timestamp along with a name for the code block and an indication of whether it is the start or end of the code bock.
13
14
This resulting file can be used alongside a tracking file created by a ``Tracker`` object for more granular analysis of specific code blocks.
14
15
15
16
:ivar str code_block_name: The name of the code block being sub-tracked.
16
17
:ivar str sub_tracking_file: The path to the file where the sub-tracking info is logged.
:param code_block_name: The name of the code block within a ``Tracker`` context that is being sub-tracked. Defaults to the file path and line number where the SubTracker context is started.
22
+
:param code_block_name: The name of the code block within a ``Tracker`` context that is being sub-tracked. Defaults to the file path followed by a colon followed by the ``code_block_attribute``.
23
+
:param code_block_attribute: Only used if ``code_block_name`` is ``None``. Defaults to the line number where the SubTracker context is started.
21
24
:param sub_tracking_file: The path to the file to log the time stamps of the code block being sub-tracked Defaults to the ID of the process where the SubTracker context is created and in CSV format.
Decorator for sub tracking calls to a specified function.
55
+
56
+
:param code_block_name: The name of the code block within a ``Tracker`` context that is being sub-tracked. Defaults to the file path followed by a colon followed by the ``code_block_attribute``.
57
+
:param code_block_attribute: Only used if ``code_block_name`` is ``None``. Defaults to the name of the decorated function i.e. the function being sub-tracked.
58
+
:param sub_tracking_file: The path to the file to log the time stamps of the code block being sub-tracked. Defaults to the ID of the process where the SubTracker context is created and in CSV format.
0 commit comments