##// END OF EJS Templates
profiling: Adding profiling.output config variable...
Nicolas Dumazet -
r8022:4f3fdfaa default
parent child Browse files
Show More
@@ -538,6 +538,18 b' paths::'
538 538 Optional. Directory or URL to use when pushing if no destination
539 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 553 [[server]]
542 554 server::
543 555 Controls generic server settings.
@@ -379,6 +379,15 b' def _runcommand(ui, options, cmd, cmdfun'
379 379 raise error.ParseError(cmd, _("invalid arguments"))
380 380
381 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 391 try:
383 392 from mercurial import lsprof
384 393 except ImportError:
@@ -393,6 +402,9 b' def _runcommand(ui, options, cmd, cmdfun'
393 402 p.disable()
394 403 stats = lsprof.Stats(p.getstats())
395 404 stats.sort()
396 stats.pprint(top=10, file=sys.stderr, climit=5)
405 stats.pprint(top=10, file=ostream, climit=5)
406
407 if output:
408 ostream.close()
397 409 else:
398 410 return checkargs()
@@ -3,7 +3,16 b''
3 3 echo % test --time
4 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 9 echo % test --profile
7 10 if "$TESTDIR/hghave" -q lsprof; then
8 hg --profile help -q help 2>&1 | grep CallCount > /dev/null || echo --profile failed
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 18 fi
General Comments 0
You need to be logged in to leave comments. Login now