Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
pyxpcom_test_tools Namespace Reference

Functions

def FindMyCounter
def CloseCounter
def GetCounterValue
def pdh_getmemusage
def getmemusage

Variables

int have_pdh = 1
 g_pdh_data = None
 getmemusage = pdh_getmemusage

Function Documentation

def pyxpcom_test_tools.CloseCounter (   hq,
  hc 
)

Definition at line 47 of file pyxpcom_test_tools.py.

00047 
00048 def CloseCounter(hq, hc):
00049     win32pdh.RemoveCounter(hc)
00050     win32pdh.CloseQuery(hq)

Definition at line 20 of file pyxpcom_test_tools.py.

00020 
00021 def FindMyCounter():
00022     pid_me = win32api.GetCurrentProcessId()
00023 
00024     object = "Process"
00025     items, instances = win32pdh.EnumObjectItems(None,None,object, -1)
00026     for instance in instances:
00027         # We use 2 counters - "ID Process" and "Working Set"
00028         counter = "ID Process"
00029         format = win32pdh.PDH_FMT_LONG
00030 
00031         hq = win32pdh.OpenQuery()
00032         path = win32pdh.MakeCounterPath( (None,object,instance, None, -1,"ID Process") )
00033         hc1 = win32pdh.AddCounter(hq, path)
00034         path = win32pdh.MakeCounterPath( (None,object,instance, None, -1,"Working Set") )
00035         hc2 = win32pdh.AddCounter(hq, path)
00036         win32pdh.CollectQueryData(hq)
00037         type, pid = win32pdh.GetFormattedCounterValue(hc1, format)
00038         if pid==pid_me:
00039             win32pdh.RemoveCounter(hc1) # not needed any more
00040             return hq, hc2
00041         # Not mine - close the query and try again
00042         win32pdh.RemoveCounter(hc1)
00043         win32pdh.RemoveCounter(hc2)
00044         win32pdh.CloseQuery(hq)
00045     else:
00046         raise RuntimeError, "Can't find myself!?"

Here is the caller graph for this function:

def pyxpcom_test_tools.GetCounterValue (   hq,
  hc 
)

Definition at line 51 of file pyxpcom_test_tools.py.

00051 
00052 def GetCounterValue(hq, hc):
00053     win32pdh.CollectQueryData(hq)
00054     format = win32pdh.PDH_FMT_LONG
00055     type, val = win32pdh.GetFormattedCounterValue(hc, format)
00056     return val

Here is the caller graph for this function:

Definition at line 71 of file pyxpcom_test_tools.py.

00071 
00072     def getmemusage():
00073         return 0

Definition at line 59 of file pyxpcom_test_tools.py.

00059 
00060 def pdh_getmemusage():
00061     global g_pdh_data
00062     if g_pdh_data is None:
00063         hq, hc = FindMyCounter()
00064         g_pdh_data = hq, hc
00065     hq, hc = g_pdh_data
00066     return GetCounterValue(hq, hc)
00067 
# The public bit

Here is the call graph for this function:


Variable Documentation

Definition at line 57 of file pyxpcom_test_tools.py.

Definition at line 69 of file pyxpcom_test_tools.py.

Definition at line 11 of file pyxpcom_test_tools.py.