Repository Details
Shared by


HelloGitHub Rating
0 ratings
Claim
Discuss
Collect
Share
4.5k
Stars
No
Chinese
Python
Language
No
Active
88
Contributors
139
Issues
Yes
Organization
None
Latest
384
Forks
None
License
More
Python 程序内存占用分析工具。示例代码:
```python
# 采用装饰器的方式引用,不影响现有代码
@profile
def my_func():
a = [1] * (10 ** 6)
b = [2] * (2 * 10 ** 7)
del b
return a
if __name__ == '__main__':
my_func()
# 运行命令:python -m memory_profiler example.py
# 输出:
Line # Mem usage Increment Line Contents
==============================================
3 @profile
4 5.97 MB 0.00 MB def my_func():
5 13.61 MB 7.64 MB a = [1] * (10 ** 6)
6 166.20 MB 152.59 MB b = [2] * (2 * 10 ** 7)
7 13.61 MB -152.59 MB del b
8 13.61 MB 0.00 MB return a
```
Included in:
Vol.45
Comments
Rating:
No comments yet