Show More
@@ -538,6 +538,18 b' paths::' | |||||
538 | Optional. Directory or URL to use when pushing if no destination |
|
538 | Optional. Directory or URL to use when pushing if no destination | |
539 | is specified. |
|
539 | is specified. | |
540 |
|
540 | |||
|
541 | [[profiling]] | |||
|
542 | profiling:: | |||
|
543 | Specifies profiling format and file output. | |||
|
544 | In this section description, 'profiling data' stands for the raw data | |||
|
545 | collected during profiling, while 'profiling report' stands for a | |||
|
546 | statistical text report generated from the profiling data. | |||
|
547 | The profiling is done using lsprof. | |||
|
548 | output;; | |||
|
549 | File path where profiling data or report should be saved. | |||
|
550 | If the file exists, it is replaced. | |||
|
551 | Default: None, data is printed on stderr | |||
|
552 | ||||
541 | [[server]] |
|
553 | [[server]] | |
542 | server:: |
|
554 | server:: | |
543 | Controls generic server settings. |
|
555 | Controls generic server settings. |
@@ -379,6 +379,15 b' def _runcommand(ui, options, cmd, cmdfun' | |||||
379 | raise error.ParseError(cmd, _("invalid arguments")) |
|
379 | raise error.ParseError(cmd, _("invalid arguments")) | |
380 |
|
380 | |||
381 | if options['profile']: |
|
381 | if options['profile']: | |
|
382 | output = ui.config('profiling', 'output') | |||
|
383 | ||||
|
384 | if output: | |||
|
385 | path = os.path.expanduser(output) | |||
|
386 | path = ui.expandpath(path) | |||
|
387 | ostream = open(path, 'wb') | |||
|
388 | else: | |||
|
389 | ostream = sys.stderr | |||
|
390 | ||||
382 | try: |
|
391 | try: | |
383 | from mercurial import lsprof |
|
392 | from mercurial import lsprof | |
384 | except ImportError: |
|
393 | except ImportError: | |
@@ -393,6 +402,9 b' def _runcommand(ui, options, cmd, cmdfun' | |||||
393 | p.disable() |
|
402 | p.disable() | |
394 | stats = lsprof.Stats(p.getstats()) |
|
403 | stats = lsprof.Stats(p.getstats()) | |
395 | stats.sort() |
|
404 | stats.sort() | |
396 |
stats.pprint(top=10, file= |
|
405 | stats.pprint(top=10, file=ostream, climit=5) | |
|
406 | ||||
|
407 | if output: | |||
|
408 | ostream.close() | |||
397 | else: |
|
409 | else: | |
398 | return checkargs() |
|
410 | return checkargs() |
@@ -3,7 +3,16 b'' | |||||
3 | echo % test --time |
|
3 | echo % test --time | |
4 | hg --time help -q help 2>&1 | grep Time > /dev/null || echo --time failed |
|
4 | hg --time help -q help 2>&1 | grep Time > /dev/null || echo --time failed | |
5 |
|
5 | |||
|
6 | hg init a | |||
|
7 | cd a | |||
|
8 | ||||
6 | echo % test --profile |
|
9 | echo % test --profile | |
7 | if "$TESTDIR/hghave" -q lsprof; then |
|
10 | if "$TESTDIR/hghave" -q lsprof; then | |
8 |
hg --profile |
|
11 | hg --profile st 2>../out || echo --profile failed | |
|
12 | grep CallCount < ../out > /dev/null || echo wrong --profile | |||
|
13 | ||||
|
14 | hg --profile --config profiling.output=../out st 2>&1 \ | |||
|
15 | || echo --profile + output to file failed | |||
|
16 | grep CallCount < ../out > /dev/null \ | |||
|
17 | || echo wrong --profile output when saving to a file | |||
9 | fi |
|
18 | fi |
General Comments 0
You need to be logged in to leave comments.
Login now