在zcml中声明配置文件的函数

collective.profiler的Python项目详细描述


简介

collective.profiler是一个帮助开发人员分析代码性能的工具。 它通过zcml声明修补代码。 它在内部使用非常好的profilehooks包。collective.profiler只是此工具的一个接口

有两个指令:

  • timecall->;通过调用提供秒数

示例

<configure
   xmlns="http://namespaces.zope.org/zope"
   xmlns:profiler="http://namespaces.plone.org/profiler"
   xmlns:five="http://namespaces.zope.org/five"
   xmlns:i18n="http://namespaces.zope.org/i18n">
  <profiler:timecall
       class="Products.CMFPlone.ActionsTool.ActionsTool"
       method="listFilteredActionsFor"
         />
 </configure>

提供有关方法的listfilteredactions调用的一些信息

当您在fg中启动zopeinstance时,您可以在启动后看到它

listFilteredActionsFor (.../eggs/Plone-3.3.5-py2.4.egg/Products/CMFPlone/ActionsTool.py:94):
   1 calls, 0.238 seconds (0.238 seconds per call)
  • profile->;打印分析结果

示例

<configure
  xmlns="http://namespaces.zope.org/zope"
  xmlns:profiler="http://namespaces.plone.org/profiler"
  xmlns:five="http://namespaces.zope.org/five"
  xmlns:i18n="http://namespaces.zope.org/i18n">
  <profiler:profile
      class="Products.CMFPlone.ActionsTool.ActionsTool"
      method="listFilteredActionsFor"
      />
</configure>

当您在fg中启动zopeinstance时,您可以在启动后看到它

 *** PROFILER RESULTS ***
listFilteredActionsFor (/Users/yboussard/.virtualenvs/dpldt/buildout/eggs/Plone-3.3.5-py2.4.egg/Products/CMFPlone/ActionsTool.py:94)
function called 1 times

        228731 function calls (211122 primitive calls) in 1.730 CPU seconds

  Ordered by: cumulative time, internal time, call count
  List reduced from 871 to 40 due to restriction <40>

  ncalls  tottime  percall  cumtime  percall filename:lineno(function)
       1    0.000    0.000    1.730    1.730 profile:0(<unbound method ActionsTool.listFilteredActionsFor>)
       1    0.000    0.000    1.729    1.729 ActionsTool.py:94(listFilteredActionsFor)
       1    0.001    0.001    1.676    1.676 ActionsTool.py:44(listActionInfos)
 195/167    0.002    0.000    1.622    0.010 ActionInformation.py:197(__getitem__)
      18    0.001    0.000    1.612    0.090 Expression.py:40(__call__)
       6    0.000    0.000    1.221    0.204 ProfilerPatch.py:19(__patched_call__)
       6    0.000    0.000    1.221    0.203 expressions.py:214(__call__)
       6    0.000    0.000    1.221    0.203 Expressions.py:144(_eval)
       6    0.000    0.000    1.086    0.181 Expressions.py:108(render)
      33    0.000    0.000    0.868    0.026 RCompile.py:68(compileAndTuplize)
      33    0.001    0.000    0.867    0.026 RCompile.py:62(compile)
      10    0.000    0.000    0.767    0.077 FSObject.py:168(_updateFromFS)
       7    0.000    0.000    0.766    0.109 FSPythonScript.py:117(_readFile)
       7    0.000    0.000    0.765    0.109 FSPythonScript.py:255(_write)
      21    0.000    0.000    0.752    0.036 PythonScript.py:275(_makeFunction)
      21    0.001    0.000    0.751    0.036 PythonScript.py:232(_compile)
      21    0.000    0.000    0.746    0.036 PythonScript.py:229(_compiler)
      21    0.000    0.000    0.746    0.036 RCompile.py:75(compile_restricted_function)
     8/3    0.000    0.000    0.693    0.231 FSPythonScript.py:137(__call__)
    10/4    0.000    0.000    0.611    0.153 Bindings.py:331(_bindAndExec)
    10/4    0.001    0.000    0.608    0.152 FSPythonScript.py:144(_exec)
       1    0.000    0.000    0.568    0.568 flashupload.py:65(can_upload)
       1    0.000    0.000    0.560    0.560 flashupload.py:62(allowed_types)
     8/3    0.000    0.000    0.545    0.182 Bindings.py:311(__call__)
       2    0.000    0.000    0.515    0.258 ZRPythonExpr.py:66(call_with_ns)
       2    0.000    0.000    0.511    0.255 FSPythonScript.py:132(__render_with_namespace__)
       1    0.000    0.000    0.469    0.469 Script (Python):1(getAllowedTypes)
     319    0.003    0.000    0.396    0.001 Connection.py:749(setstate)
     319    0.009    0.000    0.393    0.001 Connection.py:769(_setstate)
       7    0.003    0.000    0.345    0.049 PythonScript.py:395(write)
      33    0.001    0.000    0.338    0.010 RCompile.py:53(_get_tree)
     319    0.005    0.000    0.321    0.001 serialize.py:603(setGhostState)
     319    0.005    0.000    0.314    0.001 serialize.py:593(getState)
1289/638    0.023    0.000    0.301    0.000 :0(load)
 208/108    0.002    0.000    0.280    0.003 visitor.py:101(walk)
 208/108    0.002    0.000    0.278    0.003 visitor.py:59(preorder)
3858/108    0.049    0.000    0.277    0.003 visitor.py:42(dispatch)
   56/33    0.000    0.000    0.276    0.008 pycodegen.py:241(getCode)
   56/33    0.002    0.000    0.276    0.008 pyassem.py:365(getCode)
       1    0.000    0.000    0.272    0.272 constraintypes.py:243(allowedContentTypes)

选项

计时呼叫

  • immediate : If you want just a summary at program termination, use False

剖面图

  • skip : If skip is > 0, first skip calls to fn will not be profiled.

  • filename : If filename is specified, the profile stats will be stored in the named file. You can analyse it with profiler tool or pstats.Stats(filename).

  • If immediate is False, profiling results will be printed to

    sys.stdout on program termination.

  • If dirs is False only the name of the file will be printed.

    Otherwise the full path is used.

  • sort can be a list of sort keys (defaulting to [‘cumulative’,

    ‘time’, ‘calls’]). The following ones are recognized:

    'calls'      -- call count
    'cumulative' -- cumulative time
    'file'       -- file name
    'line'       -- line number
    'module'     -- file name
    'name'       -- function name
    'nfl'        -- name/file/line
    'pcalls'     -- call count
    'stdname'    -- standard name
    'time'       -- internal time
    
  • entries limits the output to the first N entries.

更改日志

0.3(2011-05-12)

  • 什么都没变。

0.2(2011-05-12)

  • 在setup.py中添加一些信息

0.1(2011-05-12)

  • 初始版本

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何从线程在swing jframe中进行更改   Java中哈希重写hashCode()   使用java添加安卓日历事件   我的java equals行出了什么问题?   java类的添加方法   java为什么在开始添加节点时列表显示为空?   Java文本文件编码   json Spring Java Rest句柄在反序列化时的类型无效   web服务java。创建代理时lang.NoClassDefFoundError   java如何获得最准确的用户位置   java在安卓中获取地图上的当前位置   在netbeans 8.0中,java不能右键单击Jframe或Jpanel   java仅比较不为空