문제

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!

도움이 되었습니까?

해결책

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;-).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top