line_profiler
line_profiler copied to clipboard
Profiling the same function multiple times
trafficstars
RIght now, I am calling a function multiple times as part of a loop. When I use line_profiler for this, it tells me that the number of hits for each line of the function is 1, which I would expect to be the number of times the loop is called.
First, am I getting that right? If so, how do I make line profiler give me execution times by function call?
what could help is instantiating new LineProfiler object in each loop iteration.
for arr_length in range(r_limit, l_limit):
line_prof = LineProfiler()
line_prof.add_function(func_to_profile)
func_to_profile(args)
line_prof.dump_stats("{}_{}".format(func_to_profile.__name__, str(r_limit)))
If that helps or not, please update the status of the issue
@petr-tik missed this somehow - super late reply! Thanks :-)