Package: dm.zope.profile
The package allows the profiling of Zope applications.
It is the successor ofProducts.ZopeProfilerforZope>=4.
It uses Python’s standard profiling support from its runtime
library  modulescProfileandpstatsand integrates it withZope.
Read the corresponding documentation to learn how to interact with
and interpret the collected profiling information.InstallationYou can install this package in the same way as you have installedZope, i.e. either viapipor viabuildout.Ensure that itsconfigure.zcmlgets executed on startup.
It defines request subscribers to collect profiling data
and the page@@profileto manage profiling or present collected data.ProfilingWhen you start aZopeinstance, profiling is disabled.
You can enable the collection of profiling data via
the page@@profile. This page also allows you to configure
the profiling and present the collected data in various
alternative ways.The configuration is split into 2 parts: theProfilerpart
controls the collection of profiling base data, theStatisticspart
controls how this information is presented.TheProfilerconfiguration allows you to specify which timer
(real time or CPU time) is used for profiling and
which requests should be profiled. For the latter task,
you can define 2 collections of regular expressions:includeandexclude. A request is not profiled if any regular expression
inexcludematches; ifincludeis not empty, then a
request is only profiled if it matches at least one of those.
Matching is always performed in search mode on the request’sPATH_INFO. When you change the timer, the
collected profiling data is cleared.TheStatisticsconfiguration essentially provides parameters
for Python’spstats.
Especially, you can select various views (stats,caller,callee),
sort according to various criteria (e.g.cumulative,internal, …),
strip directory information and control the amount of data shown.
Read the Python documentation forpstatsto get details.Note that profiling usually does not see thread switches.
This is always the case when you use a real time timer
and can also be the case with a CPU time timer (e.g. for Python 2
or on Windows). In those cases, time spend in a foreign thread
may be wrongly accounted for a profiled request. You may
consider configuring Zope to use a single worker thread
to reduce this problem.Note that both configuration and collected profiling data
is maintained in process memory; i.e. in a multi instance
Zope installation, each instance has its own private data.Note that profiling reveals important implementation details.
You should take appropriate measures to avoid that it can be
accessed by a hacker. One option is to
make it only available in development installations behind a firewall.Configurationdm.zope.profilemaintains its configuration in RAM.
As a consequence, configuration changes are lost when the process
is shut down.
You can define the initial configuration on start up via ZCML.
For this purpose, the package’smeta.zcmldefines the
directiveconfigin namespacehttp://namespaces.zope.org/dm.zope.profile.The configuration uses options with either simple values
(timer,typeandstrip_dirs) or collection values
(include,exclude,sort_by,restrictions).
Options with simple values are specified via attributes of
theconfigdirective. Individual elements of collection
values are specified viaelementsubdirectives.
Those subdirectives specify the option they provide a partial value for
via theirnameattribute and their contribution
via theirvalueattribute.example_config.zcmlcontains an example. It recreates the
code defined default conflguration (and thus serves only as an
a demontration).Note:
Currently, you cannot omit options in order to inherit them from the
the code defined default configuration: if theconfigdirective
is used, then the code defined default configuration becomes
completely irrelevant. This might change in the future.