python:面向字节码的分析器
我正在编写一个网络应用程序(http://www.checkio.org/),它允许用户编写蟒蛇代码。作为众多反馈指标之一,我希望在对此代码运行检查时启用分析。这是为了让用户能够非常粗略地了解各种解决方案的相对效率。
我需要配置文件具有(合理的)确定性。我不希望网络服务器上的其他负载导致阅读效率下降。另外,我担心某些分析器无法提供良好的测量结果,因为这些简短的脚本运行得如此之快。 timeit 模块显示一个函数运行了数千次,但如果可能的话,我希望不要在这个小功能上浪费服务器资源。
目前尚不清楚哪些标准分析器(如果有)可以满足此需求。理想情况下,探查器会给出“解释器字节码刻度”的单位,这会为每个字节码指令增加一个。这将是一个非常的测量,但满足确定性和高精度的要求。
我应该使用哪个分析系统?
I'm writing a web application (http://www.checkio.org/) which allows users to write python code. As one feedback metric among many, I'd like to enable profiling while running checks on this code. This is to allow users to get a very rough idea of the relative efficiency of various solutions.
I need the profile to be (reasonably) deterministic. I don't want other load on the web server to give a bad efficiency reading. Also, I'm worried that some profilers won't give a good measurement because these short scripts run so quickly. The timeit module shows a function being run thousands of time, but I'd like to not waste server reasources on this small features if possible.
It's not clear which (if any) of the standard profilers meet this need. Ideally the profiler would give units of "interpreter bytecode ticks" which would increment one per bytecode instruction. This would be a very rough measure, but meets the requirements of determinism and high-precision.
Which profiling system should I use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Python 的标准探查器模块提供确定性分析。
Python's standard profiler module provides deterministic profiling.
我还建议尝试一下 yappi。 (http://code.google.com/p/yappi/) 在 v0.62 中,它支持 CPU 时间分析,您可以随时停止分析器...
I also suggest giving a try to yappi. (http://code.google.com/p/yappi/) In v0.62, it supports CPU time profiling and you can stop the profiler at any time you want...