Interpreting Memory Profiling results in Python

半世苍凉 提交于 2019-12-24 20:35:41

问题


I am trying to understand how memory_profiler works in python especially in the context of for loops. In particular, as you can see the increment column here shows negative usage, which I cannot understand.

Can anyone explain the memory profile of this snippet?

The following snapshot shows a memory profile of a python code snippet:

   290 602.2148437500 MiB -53838.4804687500 MiB           for fname in self.foo.bar:
   291 602.2148437500 MiB -53460.6132812500 MiB               if fname.endswith('html'):
   292 602.7109375000 MiB -9612.6601562500 MiB                   soup = BeautifulSoup(self.foo.bar_dict[fname],'html.parser')
   294 602.7187500000 MiB -9629.5312500000 MiB                   self._process_links(soup, fname)

回答1:


The output on loops is the maximum of the times that line was executed. The second line should show the diff with respect to the previous line, but this is obviously wrong in this case.



来源:https://stackoverflow.com/questions/49588889/interpreting-memory-profiling-results-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!