@@ -166,12 +166,12 @@ class AdvancedProfiler(BaseProfiler):
166
166
verbose and you should only use this if you want very detailed reports.
167
167
"""
168
168
169
- def __init__ (self , output_filename = None , line_count_restriction = 1.0 ):
169
+ def __init__ (self , output_filename : str = None , line_count_restriction : float = 1.0 ):
170
170
"""
171
171
Prams:
172
- output_filename (str) : optionally save profile results to file instead of printing
172
+ output_filename: optionally save profile results to file instead of printing
173
173
to std out when training is finished.
174
- line_count_restriction (int|float) : this can be used to limit the number of functions
174
+ line_count_restriction: this can be used to limit the number of functions
175
175
reported for each action. either an integer (to select a count of lines),
176
176
or a decimal fraction between 0.0 and 1.0 inclusive (to select a percentage of lines)
177
177
"""
@@ -200,16 +200,16 @@ def stop(self, action_name: str) -> None:
200
200
pr .disable ()
201
201
202
202
def summary (self ) -> str :
203
- self . recorded_stats = {}
203
+ recorded_stats = {}
204
204
for action_name , pr in self .profiled_actions .items ():
205
205
s = io .StringIO ()
206
206
ps = pstats .Stats (pr , stream = s ).strip_dirs ().sort_stats ('cumulative' )
207
207
ps .print_stats (self .line_count_restriction )
208
- self . recorded_stats [action_name ] = s .getvalue ()
208
+ recorded_stats [action_name ] = s .getvalue ()
209
209
210
210
# log to standard out
211
211
output_string = f"{ os .linesep } Profiler Report{ os .linesep } "
212
- for action , stats in self . recorded_stats .items ():
212
+ for action , stats in recorded_stats .items ():
213
213
output_string += f"{ os .linesep } Profile stats for: { action } { os .linesep } { stats } "
214
214
215
215
return output_string
0 commit comments