一个简单的python程序内存分析器。
pyprofyler的Python项目详细描述
Pyprofyler
一个简单的python程序内存分析器。
安装:
sudo pip3 install git+https://github.com/AlyShmahell/PyProfyler
或
sudo pip3 install pyprofyler
示例:
frompyprofylerimportPyProfylerdefwrapped_function():array=[]foriinrange(1,1000000):array.append(i)returnarray@PyProfylerdefdecorated_function():a_list=[]foriinrange(1,1000000):a_list.append(i)returna_listif__name__=='__main__':############################################### Profiling a function by wrapping it ###############################################wrapped_profile=PyProfyler(wrapped_function)# "Not Profiled Yet" Messageprint(wrapped_profile)result=wrapped_profile()# Profile Message, through __str__print(wrapped_profile)# Function Execution Resultprint(f"execution result: {result[10]}")# Profile Message, through __getitem__print(wrapped_profile['profile'])############################################### Profiling a decorated function ################################################ "Not Profiled Yet" Messageprint(decorated_function)result=decorated_function()# Profile Message, through __str__print(decorated_function)# Function Execution Resultprint(f"execution result: {result[10]}")# Profile Message, through __getitem__print(decorated_function['profile'])