ProfilingΒΆ

Out:

------------------ Performance analysis ------------------
 Name          |   Executions | Mean time     | Total time
---------------+--------------+---------------+---------------
 list init     |            1 | 4.76837e-06 s | 4.76837e-06 s
 list reversal |         1000 | 1.05190e-06 s | 1.05190e-03 s
 program       |            1 | 1.79482e-03 s | 1.79482e-03 s
----------------------------------------------------------

from sorts.profiling import Profiler

p = Profiler()
p.start('program')

p.start('list init')
lst = list(range(200))
p.stop('list init')

for i in range(1000):
    p.start('list reversal')
    lst = lst[::-1]
    p.stop('list reversal')

p.stop('program')

print(p)

Total running time of the script: ( 0 minutes 0.004 seconds)

Gallery generated by Sphinx-Gallery