Changeset 13082 in vbox for trunk/src/libs/xpcom18a4/python
- Timestamp:
- Oct 8, 2008 2:36:19 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/python/sample/shellcommon.py
r12942 r13082 23 23 self.collector = vb.performanceCollector 24 24 25 def _update_metric_params(self):26 metrics = self.collector.getMetrics(['*'], None)27 self.metrics = {}28 for m in metrics:29 self.metrics[str(m.object) + "/" + str(m.metricName)] = m30 31 25 def setup(self, names, objects, period, nsamples): 32 26 """ Discards all previously collected values for the specified … … 35 29 """ 36 30 self.collector.setupMetrics(names, objects, period, nsamples) 37 self._update_metric_params()38 31 39 32 def enable(self, names, objects): … … 58 51 'values_as_string': pre-processed values ready for 'print' statement 59 52 """ 60 (values, names_out, objects_out, indices, lengths) = self.collector.queryMetricsData(names, objects) 53 (values, names_out, objects_out, units, scales, sequence_numbers, 54 indices, lengths) = self.collector.queryMetricsData(names, objects) 61 55 out = [] 62 56 for i in xrange(0, len(names_out)): 63 metric = self.metrics[str(objects_out[i]) + "/" + str(names_out[i])] 64 unit = str(metric.getUnit()) 65 if unit == '%': 66 scale = 1000. 57 scale = int(scales[i]) 58 if scale != 1: 67 59 fmt = '%.2f%s' 68 60 else: 69 scale = 170 61 fmt = '%d %s' 71 62 out.append({ 72 63 'name':str(names_out[i]), 73 64 'object':str(objects_out[i]), 74 'unit':str( metric.getUnit()),65 'unit':str(units[i]), 75 66 'scale':scale, 76 67 'values':[int(values[j]) for j in xrange(int(indices[i]), int(indices[i])+int(lengths[i]))], 77 'values_as_string':'['+', '.join([fmt % (int(values[j])/scale, unit ) for j in xrange(int(indices[i]), int(indices[i])+int(lengths[i]))])+']'68 'values_as_string':'['+', '.join([fmt % (int(values[j])/scale, units[i]) for j in xrange(int(indices[i]), int(indices[i])+int(lengths[i]))])+']' 78 69 }) 79 70 return out
Note:
See TracChangeset
for help on using the changeset viewer.