import profile
A = 5
def param_test():
B = 5
res = 0
for i in range(100000000):
res = B + i
return res
if __name__=='__main__':
profile.run('param_test()')
>>> ===================================== RESTART =====================================
>>>
5 function calls in 37.012 seconds #全局变量测试结果:37 秒
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 19.586 19.586 19.586 19.586 :0(range)
1 1.358 1.358 1.358 1.358 :0(setprofile)
1 0.004 0.004 35.448 35.448 <string>:1(<module>)
1 15.857 15.857 35.443 35.443 Learn.py:5(param_test)
1 0.206 0.206 37.012 37.012 profile:0(param_test())
0 0.000 0.000 profile:0(profiler)
>>> ===================================== RESTART =====================================
>>>
5 function calls in 11.504 seconds #局部变量测试结果: 11 秒
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 3.135 3.135 3.135 3.135 :0(range)
1 0.006 0.006 0.006 0.006 :0(setprofile)
1 0.000 0.000 11.497 11.497 <string>:1(<module>)
1 8.362 8.362 11.497 11.497 Learn.py:5(param_test)
1 0.000 0.000 11.504 11.504 profile:0(param_test())
0 0.000 0.000 profile:0(profiler)
#模块a.py PI = 3.14 def setPi(new): PI = new return PI
import a PI = a.setPi(3.14159) print PI;a.PI
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有