LINUX.ORG.RU

real/elapsed time в выхлопе profile/cprofile

 


0

3

Я ожидаю увидеть что нижеследующий код выполнялся одну секунду. Но, похоже, оно только считает время в контексте пользователя. Можно ли научить profile или cprofile показывать полное время? Я пробовал делать profile.Profile(timer=time.time), но получилась фигня.

Вот демонстрация проблемы:

In [1]: f=lambda: time.sleep(1)
In [2]: profile.run(f.__code__)
         5 function calls in 0.002 seconds

   Ordered by: standard name

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.000    0.000    0.002    0.002 :0(exec)
        1    0.000    0.000    0.000    0.000 :0(setprofile)
        1    0.002    0.002    0.002    0.002 :0(sleep)
        1    0.000    0.000    0.002    0.002 <ipython-input-6-624fac3f48c8>:1(<lambda>)
        1    0.000    0.000    0.002    0.002 profile:0(<code object <lambda> at 0x7f23e98a5810, file "<ipython-input-6-624fac3f48c8>", line 1>)
        0    0.000             0.000          profile:0(profiler)

★★★★★

Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.