解释Python中的内存性能分析结果 [英] Interpreting Memory Profiling results in Python

查看:128
本文介绍了解释Python中的内存性能分析结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解 memory_profiler 在python中的工作原理,尤其是在for循环的情况下.特别是,如您所见,此处的增量列显示了负用法,我无法理解.

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?

以下快照显示了python代码段的内存配置文件:

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)

推荐答案

循环中的输出是执行该行的最大次数.第二行应显示与前一行的差异,但是在这种情况下,这显然是错误的.

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.

这篇关于解释Python中的内存性能分析结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆