File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -360,6 +360,15 @@ cdef class LineProfiler:
360360 self ._c_last_time[threading.get_ident()].clear()
361361 unset_trace()
362362
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+
363372 def get_stats (self ):
364373 """
365374 Return a LineStats object containing the timings.
Original file line number Diff line number Diff line change @@ -25,6 +25,12 @@ def func(a):
2525 print (f'profiler.code_hash_map={ profiler .code_hash_map } ' )
2626 profiler .print_stats ()
2727
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+
2834
2935def _demo_explicit_profile_script ():
3036 return ub .codeblock (
You can’t perform that action at this time.
0 commit comments