VirtualBox

Changeset 13082 in vbox for trunk/src/libs/xpcom18a4/python


Ignore:
Timestamp:
Oct 8, 2008 2:36:19 PM (16 years ago)
Author:
vboxsync
Message:

PerfAPI: Backward compatibility broken. setup, enable, disable and query methods replaced with their Ex counterparts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/python/sample/shellcommon.py

    r12942 r13082  
    2323        self.collector = vb.performanceCollector
    2424
    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)] = m
    30 
    3125    def setup(self, names, objects, period, nsamples):
    3226        """ Discards all previously collected values for the specified
     
    3529        """
    3630        self.collector.setupMetrics(names, objects, period, nsamples)
    37         self._update_metric_params()
    3831
    3932    def enable(self, names, objects):
     
    5851        'values_as_string': pre-processed values ready for 'print' statement
    5952        """
    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)
    6155        out = []
    6256        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:
    6759                fmt = '%.2f%s'
    6860            else:
    69                 scale = 1
    7061                fmt = '%d %s'
    7162            out.append({
    7263                'name':str(names_out[i]),
    7364                'object':str(objects_out[i]),
    74                 'unit':str(metric.getUnit()),
     65                'unit':str(units[i]),
    7566                'scale':scale,
    7667                '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]))])+']'
    7869            })
    7970        return out
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette