import sys
from line_profiler import LineProfiler
from memory_profiler import profile
# @profile(precision=4,stream=open('memory_profiler.log','w+'))
# @profile
def my_function():
print("hello")
l = [i / 43 for i in range(100000)]
if __name__ == '__main__':
profile = LineProfiler(my_function) # 把函数传递到性能分析器
profile.enable() # 开始分析
my_function()
profile.disable() # 停止分析
profile.print_stats(sys.stdout) # 打印出性能分析结果
import sys
from line_profiler import LineProfiler
from memory_profiler import profile
@profile(precision=4,stream=open('memory_profiler.log','w+'))
def my_function():
print("hello")
l = [i / 43 for i in range(100000)]
if __name__ == '__main__':
my_function()