PyCharm profiler - results location

Answered

Hi all,

I use the built-in profiler and would like to open previous profiling results when running a script on a remote server (by SSH interpreter)

  1. Where are they stored on my machine? I cannot find anything inside the .idea project folder (local and remote)
  2. Can I change the result directory?

NOTE I use MacOS and PyCharm professional 2019.2.4.

Thanks!

1
3 comments

1) It shows you the location after execution:

2) No, it can't be changed.

1

Can this still not be changed?  Snapshots fail to save on remote interpreters because they try to save to a location on my desktop, which does not exist on the remote server.

1

Usually, it should save somewhere on your remote machine, e.g., in the /tmp directory.

 


Workaround to save the snapshots to a custom directory:

import cProfile
prf = cProfile.Profile(builtins=True)
prf.enable()

execute_your_own_code()  # e.g., main()

prf.disable()
pstat_path = "/mnt/abc/test.pstat"
prf.dump_stats(pstat_path)

This can then be executed normally (i.e., executing as any other script, not using the “Profile” execution).

The custom directory makes sense to be either some mounted (network) drive you also have access to on your own machine. Or you could choose your project folder to get the files synced, see Settings -> Build, Execution, Deployment -> Deployment -> [Choose your Server] -> Mappings -> Deployment Path.

0

Please sign in to leave a comment.