##// 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 filename,
768 filename,
769 function,
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 codestring = codepattern % (
778 codestring = codepattern % (
773 b'line',
779 prefix,
780 b'line'.rjust(spacing_len),
774 site.lineno,
781 site.lineno,
782 b''.ljust(max(0, 4 - len(str(site.lineno)))),
775 site.getsource(30),
783 site.getsource(30),
776 )
784 )
777
785
@@ -64,19 +64,19 b' A single profile is logged because file '
64
64
65 Install an extension that can sleep and guarantee a profiler has time to run
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 > import time
68 > import time
69 > from mercurial import registrar
69 > from mercurial import registrar
70 > cmdtable = {}
70 > cmdtable = {}
71 > command = registrar.command(cmdtable)
71 > command = registrar.command(cmdtable)
72 > @command(b'sleep', [], b'hg sleep')
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 > time.sleep(0.1)
74 > time.sleep(0.1)
75 > EOF
75 > EOF
76
76
77 $ cat >> $HGRCPATH << EOF
77 $ cat >> $HGRCPATH << EOF
78 > [extensions]
78 > [extensions]
79 > sleep = `pwd`/sleepext.py
79 > sleep = `pwd`/sleepext_with_a_long_filename.py
80 > EOF
80 > EOF
81
81
82 statistical profiler works
82 statistical profiler works
@@ -90,7 +90,7 b' Various statprof formatters work'
90 $ grep -v _path_stat ../out | head -n 3
90 $ grep -v _path_stat ../out | head -n 3
91 % cumulative self
91 % cumulative self
92 time seconds seconds name
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 $ cat ../out | statprofran
94 $ cat ../out | statprofran
95
95
96 $ hg --profile --config profiling.statformat=bymethod sleep 2>../out || cat ../out
96 $ hg --profile --config profiling.statformat=bymethod sleep 2>../out || cat ../out
@@ -100,8 +100,8 b' Various statprof formatters work'
100
100
101 $ hg --profile --config profiling.statformat=hotpath sleep 2>../out || cat ../out
101 $ hg --profile --config profiling.statformat=hotpath sleep 2>../out || cat ../out
102 $ cat ../out | statprofran
102 $ cat ../out | statprofran
103 $ grep sleepext.py ../out
103 $ grep sleepext_with_a_long_filename.py ../out
104 .* [0-9.]+% [0-9.]+s sleepext.py:\s*sleep line 7: time\.sleep.* (re)
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 $ hg --profile --config profiling.statformat=json sleep 2>../out || cat ../out
106 $ hg --profile --config profiling.statformat=json sleep 2>../out || cat ../out
107 $ cat ../out
107 $ cat ../out
General Comments 0
You need to be logged in to leave comments. Login now