I'm using uWSGI with the "--profiler" flag switched on but I can't seem to find the output file (if there is one), and (like many things in uWSGI) this isn't properly documented.
Asked
Active
Viewed 2,006 times
3
-
2Looks like profiler reports are getting [logged](https://github.com/unbit/uwsgi/blob/master/plugins/python/profiler.c#L36) – dhke Jun 22 '15 at 10:41
-
@dhke Thanks but I don't see any of those prints there. If it's using cProfile it should output a binary file, doesn't it? – itzhaki Jun 22 '15 at 11:47
-
4There's no reference to `cProfile` anywhere in uwsgi'S source. From what I can deduce, `--profiler=pycall` and `--profiler=pyline` are supported. Specifying a different argument seems to be [silently ignored](https://github.com/unbit/uwsgi/blob/3e5493259eac999a5b347bbd695a3d2e441dc496/plugins/python/python_plugin.c#L1233). – dhke Jun 22 '15 at 12:12
-
Thank you. You're right both times. Unfortunately this isn't the kind of profiling I've been looking for :( No memory related info there – itzhaki Jun 24 '15 at 06:51
-
Were you able to get any further on this? A possible workaround for running python with cprofile under uWSGI? – jab Oct 06 '16 at 22:41
-
@jab sorry dude, pretty much dropped it at that point – itzhaki Oct 11 '16 at 06:41
2 Answers
0
A useful trick is to use uWSGIs logger to filter out the profiler logs into their own file:
uwsgi \
<< other uwsgi options >> \
--logger profiler file:/path/to/profile.log \
--log-route profiler uWSGI Python profiler

TomDotTom
- 6,238
- 3
- 41
- 39
0
I just got this problem today. Here is a good project, you can use: https://github.com/what-studio/profiling
I used it from my code, like this:
from profiling.tracing import TracingProfiler
profiler = TracingProfiler()
profiler.start()
# ... run your program...
profiler.stop()
# save profile data to file
profiler.dump('path/to/file')

Kuko
- 26
- 2