[Erp5-report] r16859 - /erp5/trunk/products/ERP5Type/CachePlugins/RamCache.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Oct 5 13:53:14 CEST 2007


Author: ivan
Date: Fri Oct  5 13:53:14 2007
New Revision: 16859

URL: http://svn.erp5.org?rev=16859&view=rev
Log:
Remove dependency on guppy-pe (doesn't work on 64bits platforms).
Use mxBase product to measure memory usage.

Modified:
    erp5/trunk/products/ERP5Type/CachePlugins/RamCache.py

Modified: erp5/trunk/products/ERP5Type/CachePlugins/RamCache.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/CachePlugins/RamCache.py?rev=16859&r1=16858&r2=16859&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/CachePlugins/RamCache.py (original)
+++ erp5/trunk/products/ERP5Type/CachePlugins/RamCache.py Fri Oct  5 13:53:14 2007
@@ -33,16 +33,17 @@
 from BaseCache import *
 import time
 
-def calcPythonObjectMemorySize(h, i):
+def calcPythonObjectMemorySize(i):
   """ Recursive function that will 'walk' over complex python types and caclulate
       their RAM memory usage. """
-  s = h.iso(i).size
+  from mx.Tools import sizeof
+  s = sizeof(i)
   if isinstance(i, dict):
     for k, v in i.items():
-      s += calcPythonObjectMemorySize(h, k) + calcPythonObjectMemorySize(h, v)
+      s += calcPythonObjectMemorySize(k) + calcPythonObjectMemorySize(v)
   elif isinstance(i, list) or isinstance(i, tuple):
     for v in i:
-      s += calcPythonObjectMemorySize(h, v)
+      s += calcPythonObjectMemorySize(v)
   return s
 
 class RamCache(BaseCache):
@@ -129,15 +130,13 @@
       
   def getCachePluginTotalMemorySize(self):
     """ Calculate total RAM memory size of cache plugin. 
-        This function depends on guppy python module:
-        http://guppy-pe.sourceforge.net/
+        This function depends on mxBase python module:
+        http://www.egenix.com/products/python/mxBase/
         """
-    from guppy import hpy
-    h = hpy()
     total_size = 0
     cache_keys_total_size = {}
     for cache_key, cache_value in self._cache_dict[DEFAULT_CACHE_SCOPE].items():
-      cache_item_size = calcPythonObjectMemorySize(h, cache_value.getValue())
+      cache_item_size = calcPythonObjectMemorySize(cache_value.getValue())
       total_size += cache_item_size
       cache_keys_total_size[cache_key] = cache_item_size
-    return total_size, cache_keys_total_size    
+    return total_size, cache_keys_total_size      




More information about the Erp5-report mailing list