Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
MoinMoin.util.profile.TwistedProfiler Class Reference
Inheritance diagram for MoinMoin.util.profile.TwistedProfiler:
Inheritance graph
[legend]
Collaboration diagram for MoinMoin.util.profile.TwistedProfiler:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def sample
def addRequest

Public Attributes

 logfile
 requestsPerSample
 collect
 pid
 count
 requests
 data

Private Member Functions

def _callback

Private Attributes

 _getProcessOutput

Detailed Description

Twisted specific memory profiler

Customize the way we call ps, to overcome blocking problems on
twisted.

Definition at line 135 of file profile.py.


Constructor & Destructor Documentation

def MoinMoin.util.profile.TwistedProfiler.__init__ (   self,
  name,
  requestsPerSample = 100,
  collect = 0 
)
Initialized twisted profiler

Invoke Profiler.__init__ and import getProcessOuput from
twisted.

Reimplemented from MoinMoin.util.profile.Profiler.

Definition at line 142 of file profile.py.

00142 
00143     def __init__(self, name, requestsPerSample=100, collect=0):
00144         """ Initialized twisted profiler
00145 
00146         Invoke Profiler.__init__ and import getProcessOuput from
00147         twisted.
00148         """
00149         Profiler.__init__(self, name, requestsPerSample, collect)
00150         from twisted.internet.utils import getProcessOutput
00151         self._getProcessOutput = getProcessOutput


Member Function Documentation

def MoinMoin.util.profile.TwistedProfiler._callback (   self,
  data 
) [private]
Called from deferred when ps output is available

Private method, don't call this.

Definition at line 170 of file profile.py.

00170 
00171     def _callback(self, data):
00172         """ Called from deferred when ps output is available
00173 
00174         Private method, don't call this.
00175         """
00176         self.data['memory'] = data.split('\n')[1].strip()
00177         self._log()
00178 

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.util.profile.Profiler.addRequest (   self) [inherited]
Add a request to the profile

Call this for each page request.

WARNING: This is the most important call. if you don't call this
for each request - you will not have any profile data.

Invoke sample when self.count reach self.requestsPerSample.

Definition at line 68 of file profile.py.

00068 
00069     def addRequest(self):
00070         """ Add a request to the profile
00071 
00072         Call this for each page request.
00073 
00074         WARNING: This is the most important call. if you don't call this
00075         for each request - you will not have any profile data.
00076 
00077         Invoke sample when self.count reach self.requestsPerSample.
00078         """
00079         self.requests += 1
00080         self.count += 1
00081         if self.count == self.requestsPerSample:
00082             # Time for a sample
00083             self.count = 0
00084             self.sample()

Here is the call graph for this function:

Make a sample of memory usage and log it

On twisted we can't just call ps - we have to use deferred,
which will call us using a callback when its finished, and then
we log.

Since twisted continue to serve while the deferred fetch the
memory, the reading may be late in few requests.

Reimplemented from MoinMoin.util.profile.Profiler.

Definition at line 152 of file profile.py.

00152 
00153     def sample(self):
00154         """ Make a sample of memory usage and log it
00155 
00156         On twisted we can't just call ps - we have to use deferred,
00157         which will call us using a callback when its finished, and then
00158         we log.
00159 
00160         Since twisted continue to serve while the deferred fetch the
00161         memory, the reading may be late in few requests.
00162         """
00163         self._setData()
00164         # Memory will be available little later
00165         deferred = self._getProcessOutput('/bin/ps',
00166                                           ('-p', str(self.pid), '-o', 'rss'))
00167         deferred.addCallback(self._callback)

Here is the call graph for this function:


Member Data Documentation

Definition at line 150 of file profile.py.

Definition at line 62 of file profile.py.

Definition at line 64 of file profile.py.

Definition at line 66 of file profile.py.

Definition at line 60 of file profile.py.

Definition at line 63 of file profile.py.

Definition at line 65 of file profile.py.

Definition at line 61 of file profile.py.


The documentation for this class was generated from the following file: