Show More
@@ -10,6 +10,7 import contextlib | |||
|
10 | 10 | import os |
|
11 | 11 | import signal |
|
12 | 12 | import subprocess |
|
13 | import sys | |
|
13 | 14 | |
|
14 | 15 | from .i18n import _ |
|
15 | 16 | from .pycompat import ( |
@@ -57,7 +58,23 def lsprofile(ui, fp): | |||
|
57 | 58 | ) |
|
58 | 59 | ) |
|
59 | 60 | p = lsprof.Profiler() |
|
61 | try: | |
|
60 | 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 | 78 | try: |
|
62 | 79 | yield |
|
63 | 80 | finally: |
@@ -50,16 +50,30 In alias | |||
|
50 | 50 | |
|
51 | 51 | #endif |
|
52 | 52 | |
|
53 |
#if |
|
|
53 | #if serve | |
|
54 | 54 | |
|
55 | 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 | 69 | $ cat ../hg.pid >> $DAEMON_PIDS |
|
59 | 70 | $ hg -q clone -U http://localhost:$HGPORT ../clone |
|
71 | $ cat ../error.log | |
|
60 | 72 | |
|
61 | 73 | A single profile is logged because file logging doesn't append |
|
62 |
$ grep |
|
|
74 | $ grep 'Sample count:' ../profile.log | wc -l | |
|
75 | \s*1 (re) | |
|
76 | $ grep 'Total time:' ../profile.log | wc -l | |
|
63 | 77 | \s*1 (re) |
|
64 | 78 | |
|
65 | 79 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now