joerick/pyinstrument

functions like time.sleep are reported as "sleep None"

mattip opened this issue · 1 comments

mattip commented

Follow up from #223

Profiling the toy code in the issue results in the following output

1.019 <module>  profile.py:1
└─ 1.019 A  profile.py:16
   ├─ 0.705 D  profile.py:3
   │  └─ 0.705 sleep  None
   │        [2 frames hidden]  ..
   └─ 0.314 sleep  None
         [2 frames hidden]  ..

The line sleep None comes from the console renderer accessing the code_position_short frame property, which has no fallback in the if condition. What would a better repr look like?

Thanks for re-raising this, mattip! I created a PR to fix. I will say, the [2 frames hidden] bit above is a trickier nut to crack, might have another look at that now too.