##// END OF EJS Templates
show: use consistent (and possibly shorter) node lengths...
show: use consistent (and possibly shorter) node lengths `hg show` makes heavy use of shortest() to limit the length of the node hash. For the "stack" and "work" views, you are often looking at multiple lines of similar output for "lines" of work. It is visually appeasing for things to vertically align. A naive use of {shortest(node, N)} could result in variable length nodes and for the first character of the description to vary by a column or two. We implement a function to determine the longest shortest prefix for a set of revisions. The new function is used to determine the printed node length for all `hg show` views. .. feature:: show: use consistent node length in views Our previous shortest node length of 5 was arbitrarily chosen. shortest() already does the work of ensuring that a partial node isn't ambiguous with an integer revision, which is our primary risk of a collision for very short nodes. It should be safe to go with the shortest node possible. Existing code is also optimized to handle nodes as short as 4. So, we decrease the minimum hash length from 5 to 4. We also add a test demonstrating that prefix collisions increase the node length. .. feature:: show: decrease minimum displayed hash length from 5 to 4 Differential Revision: https://phab.mercurial-scm.org/D558

File last commit:

r33611:a72b2db1 stable
r34192:e6b5e732 default
Show More
test-profile.t
160 lines | 3.8 KiB | text/troff | Tads3Lexer
Matt Mackall
tests: unify test-profile
r12478 test --time
Martin Geisler
dispatch: lowercase --time message
r16933 $ hg --time help -q help 2>&1 | grep time > /dev/null
Matt Mackall
tests: unify test-profile
r12478 $ hg init a
$ cd a
Martin von Zweigbergk
tests: make test-profile.t pass if statprof didn't collect samples...
r33611 Function to check that statprof ran
$ statprofran () {
> egrep 'Sample count:|No samples recorded' > /dev/null
> }
Mads Kiilerich
tests: change odd uses of 'if hghave' to #if
r16898
Matt Mackall
tests: unify test-profile
r12478 test --profile
Martin von Zweigbergk
tests: make test-profile.t pass if statprof didn't collect samples...
r33611 $ hg st --profile 2>&1 | statprofran
profile: support --profile in alias and abbreviated version (--prof)...
r32787
Abreviated version
Martin von Zweigbergk
tests: make test-profile.t pass if statprof didn't collect samples...
r33611 $ hg st --prof 2>&1 | statprofran
profile: support --profile in alias and abbreviated version (--prof)...
r32787
In alias
Martin von Zweigbergk
tests: make test-profile.t pass if statprof didn't collect samples...
r33611 $ hg --config "alias.profst=status --profile" profst 2>&1 | statprofran
profile: support --profile in alias and abbreviated version (--prof)...
r32787
#if lsprof
Gregory Szorc
tests: explicitly use ls profiler...
r30259 $ prof='hg --config profiling.type=ls --profile'
$ $prof st 2>../out
Mads Kiilerich
tests: change odd uses of 'if hghave' to #if
r16898 $ grep CallCount ../out > /dev/null || cat ../out
Gregory Szorc
tests: explicitly use ls profiler...
r30259 $ $prof --config profiling.output=../out st
Mads Kiilerich
tests: change odd uses of 'if hghave' to #if
r16898 $ grep CallCount ../out > /dev/null || cat ../out
Gregory Szorc
tests: explicitly use ls profiler...
r30259 $ $prof --config profiling.output=blackbox --config extensions.blackbox= st
Durham Goode
profiling: allow logging profile to the blackbox...
r26191 $ grep CallCount .hg/blackbox.log > /dev/null || cat .hg/blackbox.log
Gregory Szorc
tests: explicitly use ls profiler...
r30259 $ $prof --config profiling.format=text st 2>../out
Mads Kiilerich
tests: change odd uses of 'if hghave' to #if
r16898 $ grep CallCount ../out > /dev/null || cat ../out
$ echo "[profiling]" >> $HGRCPATH
$ echo "format=kcachegrind" >> $HGRCPATH
Gregory Szorc
tests: explicitly use ls profiler...
r30259 $ $prof st 2>../out
Mads Kiilerich
tests: change odd uses of 'if hghave' to #if
r16898 $ grep 'events: Ticks' ../out > /dev/null || cat ../out
Gregory Szorc
tests: explicitly use ls profiler...
r30259 $ $prof --config profiling.output=../out st
Mads Kiilerich
tests: change odd uses of 'if hghave' to #if
r16898 $ grep 'events: Ticks' ../out > /dev/null || cat ../out
#endif
Mads Kiilerich
tests: add missing trailing 'cd ..'...
r16913
Gregory Szorc
hgweb: profile HTTP requests...
r29787 #if lsprof serve
Profiling of HTTP requests works
Gregory Szorc
tests: explicitly use ls profiler...
r30259 $ $prof --config profiling.format=text --config profiling.output=../profile.log serve -d -p $HGPORT --pid-file ../hg.pid -A ../access.log
Gregory Szorc
hgweb: profile HTTP requests...
r29787 $ cat ../hg.pid >> $DAEMON_PIDS
$ hg -q clone -U http://localhost:$HGPORT ../clone
A single profile is logged because file logging doesn't append
$ grep CallCount ../profile.log | wc -l
\s*1 (re)
#endif
Gregory Szorc
profiling: use vendored statprof and upstream enhancements (BC)...
r30316 Install an extension that can sleep and guarantee a profiler has time to run
$ cat >> sleepext.py << EOF
> import time
Yuya Nishihara
registrar: move cmdutil.command to registrar module (API)...
r32337 > from mercurial import registrar, commands
Gregory Szorc
profiling: use vendored statprof and upstream enhancements (BC)...
r30316 > cmdtable = {}
Yuya Nishihara
registrar: move cmdutil.command to registrar module (API)...
r32337 > command = registrar.command(cmdtable)
Pulkit Goyal
py3: make sure commands name are bytes in tests
r33097 > @command(b'sleep', [], 'hg sleep')
Gregory Szorc
profiling: use vendored statprof and upstream enhancements (BC)...
r30316 > def sleep(ui, *args, **kwargs):
> time.sleep(0.1)
> EOF
$ cat >> $HGRCPATH << EOF
> [extensions]
> sleep = `pwd`/sleepext.py
> EOF
statistical profiler works
Gregory Szorc
profiling: make statprof the default profiler (BC)...
r30317 $ hg --profile sleep 2>../out
Martin von Zweigbergk
tests: make test-profile.t pass if statprof didn't collect samples...
r33611 $ cat ../out | statprofran
Gregory Szorc
profiling: use vendored statprof and upstream enhancements (BC)...
r30316
Various statprof formatters work
Gregory Szorc
profiling: make statprof the default profiler (BC)...
r30317 $ hg --profile --config profiling.statformat=byline sleep 2>../out
Gregory Szorc
profiling: use vendored statprof and upstream enhancements (BC)...
r30316 $ head -n 1 ../out
% cumulative self
Martin von Zweigbergk
tests: make test-profile.t pass if statprof didn't collect samples...
r33611 $ cat ../out | statprofran
Gregory Szorc
profiling: use vendored statprof and upstream enhancements (BC)...
r30316
Gregory Szorc
profiling: make statprof the default profiler (BC)...
r30317 $ hg --profile --config profiling.statformat=bymethod sleep 2>../out
Gregory Szorc
profiling: use vendored statprof and upstream enhancements (BC)...
r30316 $ head -n 1 ../out
% cumulative self
Martin von Zweigbergk
tests: make test-profile.t pass if statprof didn't collect samples...
r33611 $ cat ../out | statprofran
Gregory Szorc
profiling: use vendored statprof and upstream enhancements (BC)...
r30316
Gregory Szorc
profiling: make statprof the default profiler (BC)...
r30317 $ hg --profile --config profiling.statformat=hotpath sleep 2>../out
Martin von Zweigbergk
tests: make test-profile.t pass if statprof didn't collect samples...
r33611 $ cat ../out | statprofran
Gregory Szorc
profiling: use vendored statprof and upstream enhancements (BC)...
r30316
Gregory Szorc
profiling: make statprof the default profiler (BC)...
r30317 $ hg --profile --config profiling.statformat=json sleep 2>../out
Gregory Szorc
profiling: use vendored statprof and upstream enhancements (BC)...
r30316 $ cat ../out
Yuya Nishihara
test-profile: allow negative time in JSON output (issue5542)...
r32060 \[\[-?\d+.* (re)
Gregory Szorc
profiling: use vendored statprof and upstream enhancements (BC)...
r30316
Gregory Szorc
statprof: require input file...
r30845 statprof can be used as a standalone module
$ $PYTHON -m mercurial.statprof hotpath
must specify --file to load
[1]
Mads Kiilerich
tests: add missing trailing 'cd ..'...
r16913 $ cd ..
Jun Wu
profiling: allow loading profiling extension before everything else...
r32417
profiler extension could be loaded before other extensions
$ cat > fooprof.py <<EOF
> from __future__ import absolute_import
> import contextlib
> @contextlib.contextmanager
> def profile(ui, fp):
> print('fooprof: start profile')
> yield
> print('fooprof: end profile')
> def extsetup(ui):
> ui.write('fooprof: loaded\n')
> EOF
$ cat > otherextension.py <<EOF
> from __future__ import absolute_import
> def extsetup(ui):
> ui.write('otherextension: loaded\n')
> EOF
$ hg init b
$ cd b
$ cat >> .hg/hgrc <<EOF
> [extensions]
> other = $TESTTMP/otherextension.py
> fooprof = $TESTTMP/fooprof.py
> EOF
$ hg root
otherextension: loaded
fooprof: loaded
$TESTTMP/b (glob)
$ HGPROF=fooprof hg root --profile
fooprof: loaded
fooprof: start profile
otherextension: loaded
$TESTTMP/b (glob)
fooprof: end profile
$ HGPROF=other hg root --profile 2>&1 | head -n 2
otherextension: loaded
unrecognized profiler 'other' - ignored
$ HGPROF=unknown hg root --profile 2>&1 | head -n 1
unrecognized profiler 'unknown' - ignored
$ cd ..