在 /cgi-bin/ 中的 Python 脚本上使用 cProfile 或 line_profile?
有没有办法在服务器上的脚本上运行 cProfile 或 line_profile?
即:我如何获得 http://www 上两种方法之一的结果.Example.com/cgi-bin/myScript.py
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定
line_profile
是什么。对于cProfile
,您只需将结果定向到稍后可以在服务器上读取的文件(取决于您对服务器的访问类型)。引用文档中的示例,
并将所有其余代码放入
def foo():
-- 然后检索该fooprof
文件并闲暇时分析它(当然,假设您的脚本运行时具有写入它的权限) 。当然,您可以确保不同的运行被分析到不同的文件中,等等——这是否实用还取决于您从托管提供商处获得的访问和权限类型,即如何您是否可以保留数据,以便以后检索该数据?这不是 Python 的问题,而是您和托管提供商之间的合同问题;-)。
Not sure what
line_profile
is. ForcProfile
, 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,
and put all the rest of the code into a
def foo():
-- then later retrieve thatfooprof
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;-).