diff --git a/mercurial/statprof.py b/mercurial/statprof.py --- a/mercurial/statprof.py +++ b/mercurial/statprof.py @@ -732,6 +732,9 @@ i += 1 if i < len(stack): child.add(stack[i:], time) + else: + # Normally this is done by the .add() calls + child.count += time root = HotNode(None) lasttime = data.samples[0].time @@ -749,12 +752,8 @@ ] if site: indent = depth * 2 - 1 - filename = b'' - function = b'' - if len(node.children) > 0: - childsite = list(pycompat.itervalues(node.children))[0].site - filename = (childsite.filename() + b':').ljust(15) - function = childsite.function + filename = (site.filename() + b':').ljust(15) + function = site.function # lots of string formatting listpattern = ( diff --git a/tests/test-profile.t b/tests/test-profile.t --- a/tests/test-profile.t +++ b/tests/test-profile.t @@ -100,6 +100,8 @@ $ hg --profile --config profiling.statformat=hotpath sleep 2>../out || cat ../out $ cat ../out | statprofran + $ grep sleepext.py ../out + .* [0-9.]+% [0-9.]+s sleepext.py:\s*sleep line 7: time\.sleep.* (re) $ hg --profile --config profiling.statformat=json sleep 2>../out || cat ../out $ cat ../out