I spent hours to find out how to profile phx.server (in dev). Without success.
I am looking for something link (pseudo code)
“mix with eprof run phx.server”
or something equivalent in iex
or some hook in the application code
You usually do not profile the running server. That would in best case only give you a profile of the connection acceptor, but not the spawned processes that actually handle the request.
You need to profile the actual controllers or views you are interested in.
1 Like
This is a pretty old thread, but I wonder if anyone has tried something like this recently. I’m trying to profile a Phoenix app and I feel this should be easier. Here’s what I tried so far:
iex -S mix phx.server
:eprof.start_profiling([self()])
- Test the application
:eprof.stop_profiling()
:eprof.analyze(:total)
However, eprof
does not log anything from the app itself. Using fprof
though, I can get some calls to the application, but the summary format you get is pretty wild:
iex -S mix phx.server
:fprof.start()
:fprof.trace([:start, procs: :all])
- Test the application
:fprof.trace(:stop)
:fprof.profile()
:fprof.analyse(:totals)
1 Like