I want to run both cProfiler (For time measurement, mainly) and also a memory profiler that I found here. However, both require the -m command line argument to be given, which doesn't exactly play nicely.
Is there a way to have both running? All I've managed to do so far is get the interpreter yelling at me.
If you need any more information, let me know and I'll do my best to provide it. Thanks in advance!
While it's now evident to me that you can't use two -m arguments on the same file, I managed to pull together something of a solution. It's a bit round-about, and not exactly perfect, though. I used 2 .bat files, which can be seen here. On the left hand side is the .bat that handles cProfiler, and on the right is the .bat that handles the memory profiler.
The code for the python programs seen in the .bat handling the memory profiler can be seen here and here.
The first program adds # to the line directly above the function in my main code here, which means that the program can actually run, and cProfiler can do its thing.
The second program removes that #, meaning that the memory profiler can work.
For this system to work properly with my layout, the "@profile" needs to be commented out in the first place.
It's a bit kludgey, and could use some refinement to automate it further (Such as having to specify the name of the file in the .bat file handling the memory profiler), but it'll do for now. I also realize that it's quite a specific case, but who knows, maybe someone is in the exact same position as I was...
It is not possible to start two modules using two
-m
arguments. This is because the command line arguments after-m
are all given to the named module assys.argv
. This is not described explicitly in the documentation but you can try it out experimentally.Create two python files
a.py
andb.py
.Contents of
a.py
:Contents of
b.py
:Now try to run both using two
-m
arguments:Output:
As you can see module b is never started because the second
-m
is not handled by python. It is given to module a to handle.