2010-09-26 22:44:49 +04:00
|
|
|
test --time
|
|
|
|
|
2012-06-12 16:18:18 +04:00
|
|
|
$ hg --time help -q help 2>&1 | grep time > /dev/null
|
2010-09-26 22:44:49 +04:00
|
|
|
$ hg init a
|
|
|
|
$ cd a
|
|
|
|
|
2012-06-10 15:01:40 +04:00
|
|
|
#if lsprof
|
|
|
|
|
2010-09-26 22:44:49 +04:00
|
|
|
test --profile
|
|
|
|
|
2016-08-17 18:52:15 +03:00
|
|
|
$ prof='hg --config profiling.type=ls --profile'
|
|
|
|
|
|
|
|
$ $prof st 2>../out
|
2012-06-10 15:01:40 +04:00
|
|
|
$ grep CallCount ../out > /dev/null || cat ../out
|
|
|
|
|
2016-08-17 18:52:15 +03:00
|
|
|
$ $prof --config profiling.output=../out st
|
2012-06-10 15:01:40 +04:00
|
|
|
$ grep CallCount ../out > /dev/null || cat ../out
|
|
|
|
|
2016-08-17 18:52:15 +03:00
|
|
|
$ $prof --config profiling.output=blackbox --config extensions.blackbox= st
|
2015-09-08 21:39:52 +03:00
|
|
|
$ grep CallCount .hg/blackbox.log > /dev/null || cat .hg/blackbox.log
|
|
|
|
|
2016-08-17 18:52:15 +03:00
|
|
|
$ $prof --config profiling.format=text st 2>../out
|
2012-06-10 15:01:40 +04:00
|
|
|
$ grep CallCount ../out > /dev/null || cat ../out
|
|
|
|
|
|
|
|
$ echo "[profiling]" >> $HGRCPATH
|
|
|
|
$ echo "format=kcachegrind" >> $HGRCPATH
|
|
|
|
|
2016-08-17 18:52:15 +03:00
|
|
|
$ $prof st 2>../out
|
2012-06-10 15:01:40 +04:00
|
|
|
$ grep 'events: Ticks' ../out > /dev/null || cat ../out
|
|
|
|
|
2016-08-17 18:52:15 +03:00
|
|
|
$ $prof --config profiling.output=../out st
|
2012-06-10 15:01:40 +04:00
|
|
|
$ grep 'events: Ticks' ../out > /dev/null || cat ../out
|
|
|
|
|
2016-08-15 04:37:24 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if lsprof serve
|
|
|
|
|
|
|
|
Profiling of HTTP requests works
|
|
|
|
|
2016-08-17 18:52:15 +03:00
|
|
|
$ $prof --config profiling.format=text --config profiling.output=../profile.log serve -d -p $HGPORT --pid-file ../hg.pid -A ../access.log
|
2016-08-15 04:37:24 +03:00
|
|
|
$ 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)
|
|
|
|
|
2012-06-10 15:01:40 +04:00
|
|
|
#endif
|
2012-06-11 03:40:51 +04:00
|
|
|
|
2016-11-05 06:50:38 +03:00
|
|
|
Install an extension that can sleep and guarantee a profiler has time to run
|
|
|
|
|
|
|
|
$ cat >> sleepext.py << EOF
|
|
|
|
> import time
|
2016-01-09 17:07:20 +03:00
|
|
|
> from mercurial import registrar, commands
|
2016-11-05 06:50:38 +03:00
|
|
|
> cmdtable = {}
|
2016-01-09 17:07:20 +03:00
|
|
|
> command = registrar.command(cmdtable)
|
2016-11-05 06:50:38 +03:00
|
|
|
> @command('sleep', [], 'hg sleep')
|
|
|
|
> def sleep(ui, *args, **kwargs):
|
|
|
|
> time.sleep(0.1)
|
|
|
|
> EOF
|
|
|
|
|
|
|
|
$ cat >> $HGRCPATH << EOF
|
|
|
|
> [extensions]
|
|
|
|
> sleep = `pwd`/sleepext.py
|
|
|
|
> EOF
|
|
|
|
|
|
|
|
statistical profiler works
|
|
|
|
|
2016-11-05 07:44:25 +03:00
|
|
|
$ hg --profile sleep 2>../out
|
2016-11-05 06:50:38 +03:00
|
|
|
$ grep Sample ../out
|
|
|
|
Sample count: \d+ (re)
|
|
|
|
|
|
|
|
Various statprof formatters work
|
|
|
|
|
2016-11-05 07:44:25 +03:00
|
|
|
$ hg --profile --config profiling.statformat=byline sleep 2>../out
|
2016-11-05 06:50:38 +03:00
|
|
|
$ head -n 1 ../out
|
|
|
|
% cumulative self
|
|
|
|
$ grep Sample ../out
|
|
|
|
Sample count: \d+ (re)
|
|
|
|
|
2016-11-05 07:44:25 +03:00
|
|
|
$ hg --profile --config profiling.statformat=bymethod sleep 2>../out
|
2016-11-05 06:50:38 +03:00
|
|
|
$ head -n 1 ../out
|
|
|
|
% cumulative self
|
|
|
|
$ grep Sample ../out
|
|
|
|
Sample count: \d+ (re)
|
|
|
|
|
2016-11-05 07:44:25 +03:00
|
|
|
$ hg --profile --config profiling.statformat=hotpath sleep 2>../out
|
2016-11-05 06:50:38 +03:00
|
|
|
$ grep Sample ../out
|
|
|
|
Sample count: \d+ (re)
|
|
|
|
|
2016-11-05 07:44:25 +03:00
|
|
|
$ hg --profile --config profiling.statformat=json sleep 2>../out
|
2016-11-05 06:50:38 +03:00
|
|
|
$ cat ../out
|
2017-04-20 16:45:45 +03:00
|
|
|
\[\[-?\d+.* (re)
|
2016-11-05 06:50:38 +03:00
|
|
|
|
2017-01-19 09:45:07 +03:00
|
|
|
statprof can be used as a standalone module
|
|
|
|
|
|
|
|
$ $PYTHON -m mercurial.statprof hotpath
|
|
|
|
must specify --file to load
|
|
|
|
[1]
|
|
|
|
|
2012-06-11 03:40:51 +04:00
|
|
|
$ cd ..
|