рассмотрим следующий пример:
import hotshot
import hotshot.stats
import time
def test_sleep():
time.sleep(1)
def main():
prof = hotshot.Profile("lol.prof")
prof.runcall(test_sleep)
prof.close()
stats = hotshot.stats.load("lol.prof")
stats.sort_stats("time", "calls")
stats.print_stats(20)
if __name__ == "__main__":
main()
Я получил этот вывод:
debian:# python lol.py
1 function calls in 1.000 CPU seconds
Ordered by: internal time, call count
ncalls tottime percall cumtime percall filename:lineno(function)
1 1.000 1.000 1.000 1.000 lol.py:6(test_sleep)
0 0.000 0.000 profile:0(profiler)
Я ожидаю, что у меня будет 0 сек. Времени процессора и 1 сек. Времени стены.
Я ожидаю 1 секунду процессора в случае занятого цикла, а не в режиме сна.
Может кто-нибудь объяснить, почему я получаю такие результаты?
Спасибо!