Question

Is there a way to run cProfile or line_profile on a script on a server?

ie: how could I get the results for one of the two methods on http://www.Example.com/cgi-bin/myScript.py

Thanks!

Was it helpful?

Solution

Not sure what line_profile is. For cProfile, you just need to direct the results to a file you can later read on the server (depending on what kind of access you have to the server).

To quote the example from the docs,

import cProfile
cProfile.run('foo()', 'fooprof')

and put all the rest of the code into a def foo(): -- then later retrieve that fooprof file and analyze it at leisure (assuming your script runs with permissions to write it in the first place, of course).

Of course you can ensure different runs get profiled into different files, etc, etc -- whether this is practical also depends on what kind of access and permissions you're getting from your hosting provider, i.e., how are you allowed to persist data, in a way that lets you retrieve that data later? That's not a question of Python, it's a question of contracts between you and your hosting provider;-).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top