http://docs.python.org/2/library/profile.html#module-cProfile
私たちは、コールが再帰を経て誘導されなかったことを意味するプリミティブを定義します。関数が再帰していない場合
...、これらの2つの値はcalls
またはncalls
によってソート同じ
が同じです。 (例えば、3分の43)最初の列内の2つの数字があり
は、次いで、後者は、プリミティブコールの数であり、前者はコールの実際の数です。関数が再帰していない場合、これら2つの値が同じで、かつ唯一の図は が印刷されることに注意してください:
In [43]: def a(i):
....: if i == 0:
....: return
....: a(i-1)
....:
In [54]: %prun a(0)
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 <ipython-input-43-25b7f3d268b8>:1(a)
In [55]: %prun a(1)
ncalls tottime percall cumtime percall filename:lineno(function)
2/1 0.000 0.000 0.000 0.000 <ipython-input-43-25b7f3d268b8>:1(a)
In [56]: %prun a(3)
ncalls tottime percall cumtime percall filename:lineno(function)
4/1 0.000 0.000 0.000 0.000 <ipython-input-43-25b7f3d268b8>:1(a)