- 挺好,原作者太忙了,作为他的... 我来代替更一下。
- 祝他半期不挂!
- 谁曾侍秋风画扇。遮掩几时落寞。短梳牛角理红妆。阶前梧桐老,扉下虫丝长。
- 点墨胸中话短长。南北天桥谁架?再相逢羞谈过往。今朝晨露好,融化笺上霜。
cProfile测试
for i in range(for_count):
for i in range(for_count):
>>>cProfile.run('simulate(21)')
14 function calls in 5.770 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 1.241 1.241 5.770 5.770 0.py:11(simulate)
1 0.000 0.000 0.503 0.503 0.py:5(delay1)
4 0.000 0.000 4.026 1.006 0.py:8(delay2)
1 0.000 0.000 5.770 5.770 <string>:1(<module>)
1 0.000 0.000 5.770 5.770 {built-in method builtins.exec}
5 4.529 0.906 4.529 0.906 {built-in method time.sleep}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
- ncall:函数运行次数
- tottime: 函数的总的运行时间减去函数中调用子函数的运行时间
- 第一个percall:percall = tottime / nclall
- cumtime:函数及其所有子函数调整的运行时间
- 第二个percall:percall = cumtime / nclall
numba的使用
for i in range(for_count):
for i in range(for_count):
cProfile.run('simulate(100)')
4 function calls in 0.000 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 0.py:5(simulate)
1 0.000 0.000 0.000 0.000 <string>:1(<module>)
1 0.000 0.000 0.000 0.000 {built-in method builtins.exec}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
cProfile.run('simulate(100)')
4 function calls in 1.234 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 1.234 1.234 1.234 1.234 0.py:6(simulate)
1 0.000 0.000 1.234 1.234 <string>:1(<module>)
1 0.000 0.000 1.234 1.234 {built-in method builtins.exec}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
- @njit和@jit(nopython=True)具有相类似的功能