1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-03-03 16:57:51 +00:00

Instrumentation: Update to populate missing 'sample_rate_hz` attributes

To conform with the Instrumentation API each instrument should populate
the `sample_rate_hz` attribute with the relevant information.
This commit is contained in:
Marc Bonnici 2017-08-03 16:41:10 +01:00
parent 30fdfc23d3
commit 7dd934a5d8
3 changed files with 10 additions and 5 deletions

View File

@ -46,6 +46,7 @@ class AcmeCapeInstrument(Instrument):
self.host = host
self.iio_device = iio_device
self.buffer_size = buffer_size
self.sample_rate_hz = 100
if self.iio_capture is None:
raise HostError('Missing iio-capture binary')
self.command = None

View File

@ -16,6 +16,7 @@ class FramesInstrument(Instrument):
self.collector_target = collector_target
self.period = period
self.keep_raw = keep_raw
self.sample_rate_hz = 1 / self.period
self.collector = None
self.header = None
self._need_reset = True

View File

@ -28,10 +28,10 @@ class Gem5PowerInstrument(Instrument):
mode = CONTINUOUS
roi_label = 'power_instrument'
def __init__(self, target, power_sites):
'''
Parameter power_sites is a list of gem5 identifiers for power values.
Parameter power_sites is a list of gem5 identifiers for power values.
One example of such a field:
system.cluster0.cores0.power_model.static_power
'''
@ -51,6 +51,9 @@ class Gem5PowerInstrument(Instrument):
self.add_channel(field, 'power')
self.target.gem5stats.book_roi(self.roi_label)
self.sample_period_ns = 10000000
# Sample rate must remain unset as gem5 does not provide samples
# at regular intervals therefore the reported timestamp should be used.
self.sample_rate_hz = None
self.target.gem5stats.start_periodic_dump(0, self.sample_period_ns)
self._base_stats_dump = 0
@ -59,17 +62,17 @@ class Gem5PowerInstrument(Instrument):
def stop(self):
self.target.gem5stats.roi_end(self.roi_label)
def get_data(self, outfile):
active_sites = [c.site for c in self.active_channels]
with open(outfile, 'wb') as wfh:
writer = csv.writer(wfh)
writer.writerow([c.label for c in self.active_channels]) # headers
for rec, rois in self.target.gem5stats.match_iter(active_sites,
for rec, rois in self.target.gem5stats.match_iter(active_sites,
[self.roi_label], self._base_stats_dump):
writer.writerow([float(rec[s]) for s in active_sites])
return MeasurementsCsv(outfile, self.active_channels)
def reset(self, sites=None, kinds=None, channels=None):
super(Gem5PowerInstrument, self).reset(sites, kinds, channels)
self._base_stats_dump = self.target.gem5stats.next_dump_no()