##// END OF EJS Templates
statprof: separate functions and "line", assume 4 digit line numbers...
Kyle Lippincott -
r46639:8b0a3ff5 default
parent child Browse files
Show More
@@ -768,10 +768,18 b' def display_hotpath(data, fp, limit=0.05'
768 768 filename,
769 769 function,
770 770 )
771 codepattern = b'%' + (b'%d' % (55 - len(liststring))) + b's %d: %s'
771 # 4 to account for the word 'line'
772 spacing_len = max(4, 55 - len(liststring))
773 prefix = b''
774 if spacing_len == 4:
775 prefix = b', '
776
777 codepattern = b'%s%s %d: %s%s'
772 778 codestring = codepattern % (
773 b'line',
779 prefix,
780 b'line'.rjust(spacing_len),
774 781 site.lineno,
782 b''.ljust(max(0, 4 - len(str(site.lineno)))),
775 783 site.getsource(30),
776 784 )
777 785
@@ -64,19 +64,19 b' A single profile is logged because file '
64 64
65 65 Install an extension that can sleep and guarantee a profiler has time to run
66 66
67 $ cat >> sleepext.py << EOF
67 $ cat >> sleepext_with_a_long_filename.py << EOF
68 68 > import time
69 69 > from mercurial import registrar
70 70 > cmdtable = {}
71 71 > command = registrar.command(cmdtable)
72 72 > @command(b'sleep', [], b'hg sleep')
73 > def sleep(ui, *args, **kwargs):
73 > def sleep_for_at_least_one_stat_cycle(ui, *args, **kwargs):
74 74 > time.sleep(0.1)
75 75 > EOF
76 76
77 77 $ cat >> $HGRCPATH << EOF
78 78 > [extensions]
79 > sleep = `pwd`/sleepext.py
79 > sleep = `pwd`/sleepext_with_a_long_filename.py
80 80 > EOF
81 81
82 82 statistical profiler works
@@ -90,7 +90,7 b' Various statprof formatters work'
90 90 $ grep -v _path_stat ../out | head -n 3
91 91 % cumulative self
92 92 time seconds seconds name
93 * sleepext.py:*:sleep (glob)
93 * sleepext_with_a_long_filename.py:*:sleep_for_at_least_one_stat_cycle (glob)
94 94 $ cat ../out | statprofran
95 95
96 96 $ hg --profile --config profiling.statformat=bymethod sleep 2>../out || cat ../out
@@ -100,8 +100,8 b' Various statprof formatters work'
100 100
101 101 $ hg --profile --config profiling.statformat=hotpath sleep 2>../out || cat ../out
102 102 $ cat ../out | statprofran
103 $ grep sleepext.py ../out
104 .* [0-9.]+% [0-9.]+s sleepext.py:\s*sleep line 7: time\.sleep.* (re)
103 $ grep sleepext_with_a_long_filename.py ../out
104 .* [0-9.]+% [0-9.]+s sleepext_with_a_long_filename.py:\s*sleep_for_at_least_one_stat_cycle, line 7: time\.sleep.* (re)
105 105
106 106 $ hg --profile --config profiling.statformat=json sleep 2>../out || cat ../out
107 107 $ cat ../out
General Comments 0
You need to be logged in to leave comments. Login now