##// END OF EJS Templates
branching: merge with stable
marmoute -
r52735:3785814b merge default
parent child Browse files
Show More
@@ -10,6 +10,7 import contextlib
10 import os
10 import os
11 import signal
11 import signal
12 import subprocess
12 import subprocess
13 import sys
13
14
14 from .i18n import _
15 from .i18n import _
15 from .pycompat import (
16 from .pycompat import (
@@ -57,7 +58,23 def lsprofile(ui, fp):
57 )
58 )
58 )
59 )
59 p = lsprof.Profiler()
60 p = lsprof.Profiler()
60 p.enable(subcalls=True)
61 try:
62 p.enable(subcalls=True)
63 except ValueError as exc:
64 if str(exc) != "Another profiling tool is already active":
65 raise
66 if not hasattr(sys, "monitoring"):
67 raise
68 # python >=3.12 prevent more than one profiler to run at the same
69 # time, tries to improve the report to help the user understand
70 # what is going on.
71 other_tool_name = sys.monitoring.get_tool(sys.monitoring.PROFILER_ID)
72 if other_tool_name == "cProfile":
73 msg = 'cannot recursively call `lsprof`'
74 raise error.Abort(msg) from None
75 else:
76 m = 'failed to start "lsprofile"; another profiler already running: %s'
77 raise error.Abort(_(m) % other_tool_name) from None
61 try:
78 try:
62 yield
79 yield
63 finally:
80 finally:
@@ -50,16 +50,30 In alias
50
50
51 #endif
51 #endif
52
52
53 #if lsprof serve
53 #if serve
54
54
55 Profiling of HTTP requests works
55 Profiling of HTTP requests works
56
56
57 $ prof --config profiling.format=text --config profiling.output=../profile.log serve -d -p $HGPORT --pid-file ../hg.pid -A ../access.log
57 $ stats_prof () {
58 > hg --config profiling.type=stat --profile $@
59 > }
60
61 $ stats_prof \
62 > --config profiling.format=text \
63 > --config profiling.output=../profile.log \
64 > serve -d \
65 > -p $HGPORT \
66 > --pid-file ../hg.pid \
67 > -A ../access.log \
68 > --errorlog ../error.log
58 $ cat ../hg.pid >> $DAEMON_PIDS
69 $ cat ../hg.pid >> $DAEMON_PIDS
59 $ hg -q clone -U http://localhost:$HGPORT ../clone
70 $ hg -q clone -U http://localhost:$HGPORT ../clone
71 $ cat ../error.log
60
72
61 A single profile is logged because file logging doesn't append
73 A single profile is logged because file logging doesn't append
62 $ grep CallCount ../profile.log | wc -l
74 $ grep 'Sample count:' ../profile.log | wc -l
75 \s*1 (re)
76 $ grep 'Total time:' ../profile.log | wc -l
63 \s*1 (re)
77 \s*1 (re)
64
78
65 #endif
79 #endif
General Comments 0
You need to be logged in to leave comments. Login now