CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Attributes | Private Attributes
dqmMemoryStats.HistogramAnalyzer Class Reference
Inheritance diagram for dqmMemoryStats.HistogramAnalyzer:

Public Member Functions

def __init__
 
def analyze
 
def difference
 
def group
 

Static Public Attributes

dictionary BIN_SIZE
 

Private Attributes

 _all
 

Detailed Description

Definition at line 11 of file dqmMemoryStats.py.

Constructor & Destructor Documentation

def dqmMemoryStats.HistogramAnalyzer.__init__ (   self)

Definition at line 20 of file dqmMemoryStats.py.

20 
21  def __init__(self):
22  self._all = {}

Member Function Documentation

def dqmMemoryStats.HistogramAnalyzer.analyze (   self,
  fn,
  obj 
)

Definition at line 23 of file dqmMemoryStats.py.

References dqmMemoryStats.HistogramAnalyzer._all, dqmMemoryStats.HistogramEntry, and str.

23 
24  def analyze(self, fn, obj):
25  name = fn.split("/")[-1]
26 
27  if hasattr(obj, 'ClassName'):
28  # this is a root type
29  t = str(obj.ClassName())
30  bin_size = self.BIN_SIZE.get(t, None)
31  if bin_size is None:
32  sys.stderr.write("warning: unknown root type: %s\n" % t)
33  sys.stderr.flush()
34  bin_size = 8
35 
36  bin_count = obj.GetNcells()
37  extra = len(fn)
38  total_bytes = bin_count * bin_size + extra
39 
40  self._all[fn] = HistogramEntry(t, bin_size, bin_count, extra, total_bytes)
41  else:
42  t = str(type(obj))
43  #bin_count, bin_size, extra = 0, 0, len(str(obj)) + len(fn)
44  # assume constant size for strings
45  bin_count, bin_size, extra = 0, 0, 10 + len(fn)
46  total_bytes = bin_count * bin_size + extra
47 
48  self._all[fn] = HistogramEntry(t, bin_size, bin_count, extra, total_bytes)
tuple HistogramEntry
#define str(s)
def dqmMemoryStats.HistogramAnalyzer.difference (   self,
  ref 
)

Definition at line 60 of file dqmMemoryStats.py.

References dqmMemoryStats.HistogramAnalyzer._all, and dqmMemoryStats.HistogramEntry.

60 
61  def difference(self, ref):
62  results = HistogramAnalyzer()
63  results._all = dict(self._all)
64 
65  zero = HistogramEntry("null", 0, 0, 0, 0)
66  def cmp(a, b):
67  return HistogramEntry(b.type, b.bin_size,
68  a.bin_count - b.bin_count,
69  a.extra - b.extra,
70  a.total_bytes - b.total_bytes )
71 
72  for k, refv in ref._all.items():
73  results._all[k] = cmp(self._all.get(k, zero), refv)
74 
75  return results
76 
tuple HistogramEntry
def dqmMemoryStats.HistogramAnalyzer.group (   self,
  level,
  countObjects 
)

Definition at line 49 of file dqmMemoryStats.py.

References join().

49 
50  def group(self, level, countObjects):
51  group_stats = {}
52 
53  for k, v in self._all.items():
54  group_key = "/".join(k.split("/")[:level])
55 
56  current = group_stats.get(group_key, 0)
57  group_stats[group_key] = current + (1 if countObjects else v.total_bytes)
58 
59  return group_stats
static std::string join(char **cmd)
Definition: RemoteFile.cc:19

Member Data Documentation

dqmMemoryStats.HistogramAnalyzer._all
private

Definition at line 21 of file dqmMemoryStats.py.

Referenced by dqmMemoryStats.HistogramAnalyzer.analyze(), and dqmMemoryStats.HistogramAnalyzer.difference().

dictionary dqmMemoryStats.HistogramAnalyzer.BIN_SIZE
static
Initial value:
1 = {
2  'TH1S': 2, 'TH2S': 2,
3  'TH1F': 4, 'TH2F': 4,
4  'TH1D': 8, 'TH2D': 8,
5  'TH3F': 4,
6  'TProfile': 8, 'TProfile2D': 8,
7  }

Definition at line 12 of file dqmMemoryStats.py.