• 安装

    首先安装memory_profiler和psutil

    pip install memory_profiler

    pip install psutil

  • 在需要分析的函数前面添加装饰器@profile

@profile()
def call():
a = list()
for i in range(10000 * 100):
a .append(i)

运行call后的输出:

Line # Mem usage Increment Line Contents

283 40.1 MiB 40.1 MiB @profile

284 def call():

285 40.1 MiB 0.0 MiB a = list()

286 44.1 MiB 0.0 MiB for i in range(10000 * 10):

287 44.1 MiB 0.3 MiB a .append(i)

最新文章

  1. RequireJS与Backbone简单整合
  2. C#数据库导出(入)TXT
  3. CSS 行内样式 页内样式 外部样式
  4. yii 多模板
  5. SQL中获取最近的N个半年度
  6. Solr Schema.xml和solrconfig.xml分析(转)
  7. [课程相关]homework-03
  8. shutdown彻底关闭tomcat,以及多线程关闭
  9. ng-class css样式
  10. Notification(一个)——使用演示样本的基础知识
  11. [oracle]查询一个表中数据的插入时间
  12. 【转】【Android】1分钟不用改任何代码在Eclipse中使用AAR
  13. MongoDB 创建基础索引、组合索引、唯一索引以及优化
  14. Bootstrap之表格、表单应用
  15. php测试for/while/foreach循环速度对比
  16. Node.js中,获取req请求的原始IP
  17. [转]收藏的Extjs 多表头插件GroupHeaderGrid
  18. 前端工具Rythem介绍
  19. C语言中Union类型的使用方法
  20. .Net Mvc5Filter与权限认证扩展

热门文章

  1. Spring Boot 中使用 spring-boot-devtools (使用 Gradle 作为构建工具)
  2. GitHub最著名的20个Python机器学习项目
  3. Oracle10g 64位 在Windows 2008 Server R2 中的安装 DBconsole无法启动
  4. ORA-00346,借助_allow_resetlogs_corruption开库
  5. leetcode 142. 环形链表 II(c++)
  6. KVM/QEMU/qemu-kvm/libvirt 概念全解
  7. Binder进程与线程ProcessState以及IPCThreadState
  8. Winform 开源控件库( Sheng.Winform.Controls)
  9. hbase的TTL机制清除opentsdb的超时数据
  10. 【BASIS系列】SAP /usr/sap//DVEBMGS00满了怎么处理