File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -360,6 +360,15 @@ cdef class LineProfiler:
360
360
self ._c_last_time[threading.get_ident()].clear()
361
361
unset_trace()
362
362
363
+ def reset_stats (self ):
364
+ """
365
+ Reset the currently accumulated timings information.
366
+ """
367
+ it = self ._c_code_map.begin()
368
+ while it != self ._c_code_map.end():
369
+ cython.operator.dereference(it).second.clear()
370
+ cython.operator.preincrement(it)
371
+
363
372
def get_stats (self ):
364
373
"""
365
374
Return a LineStats object containing the timings.
Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ def func(a):
25
25
print (f'profiler.code_hash_map={ profiler .code_hash_map } ' )
26
26
profiler .print_stats ()
27
27
28
+ profiler .reset_stats ()
29
+ for code in profiler .code_hash_map :
30
+ for entry in profiler .code_hash_map [code ]:
31
+ assert entry in profiler .c_code_map
32
+ assert len (profiler .c_code_map [entry ]) == 0
33
+
28
34
29
35
def _demo_explicit_profile_script ():
30
36
return ub .codeblock (
You can’t perform that action at this time.
0 commit comments