How to use the devlib.instrument.MeasurementsCsv function in devlib

To help you get started, we’ve selected a few devlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ARM-software / devlib / devlib / instrument / monsoon.py View on Github external
writer.writerow(row)

            # Write data
            for line in stdout.splitlines():
                # Each output line is a main_output, usb_output measurement pair.
                # (If our user only requested one channel we still collect both,
                # and just ignore one of them)
                output, usb = line.split()
                row = []
                if 'output' in active_sites:
                    row.append(output)
                if 'USB' in active_sites:
                    row.append(usb)
                writer.writerow(row)

        return MeasurementsCsv(outfile, self.active_channels, self.sample_rate_hz)
github ARM-software / devlib / devlib / instrument / arm_energy_probe.py View on Github external
with csvwriter(outfile) as writer:
                for row in reader:
                    if skip_header == 1:
                        writer.writerow(active_channels)
                        skip_header = 0
                        continue
                    if len(row) < len(active_channels):
                        continue
                    # all data are in micro (seconds/watt)
                    new = [float(row[i])/1000000 for i in active_indexes]
                    writer.writerow(new)

        self.output_fd_error.close()
        shutil.rmtree(self.output_directory)

        return MeasurementsCsv(outfile, self.active_channels, self.sample_rate_hz)
github ARM-software / devlib / devlib / instrument / daq.py View on Github external
for raw_row in row_iter:
                    raw_row = list(chain.from_iterable(raw_row))
                    raw_row.insert(0, _read_rows.row_time_s)
                    yield raw_row
                    _read_rows.row_time_s += 1.0 / self.sample_rate_hz

            _read_rows.row_time_s = self.target_monotonic_clock_at_start

            with csvwriter(outfile) as writer:
                field_names = [c.label for c in self.active_channels]
                writer.writerow(field_names)
                for raw_row in _read_rows():
                    row = [raw_row[channel_order.index(f)] for f in field_names]
                    writer.writerow(row)

            return MeasurementsCsv(outfile, self.active_channels, self.sample_rate_hz)
        finally:
            for fh in file_handles:
                fh.close()
github ARM-software / devlib / devlib / instrument / frames.py View on Github external
def get_data(self, outfile):
        if self.keep_raw:
            self._raw_file = outfile + '.raw'
        self.collector.process_frames(self._raw_file)
        active_sites = [chan.label for chan in self.active_channels]
        self.collector.write_frames(outfile, columns=active_sites)
        return MeasurementsCsv(outfile, self.active_channels, self.sample_rate_hz)
github ARM-software / devlib / devlib / derived / fps.py View on Github external
if frame_count:
            duration = end_vsync - start_vsync
            fps = (1e9 * frame_count) / float(duration)
        else:
            duration = 0
            fps = 0

        csv_file = self._get_csv_file_name(measurements_csv.path)
        with csvwriter(csv_file) as writer:
            writer.writerow(['fps'])
            writer.writerows(per_frame_fps)

        return [DerivedMetric('fps', fps, 'fps'),
                DerivedMetric('total_frames', frame_count, 'frames'),
                MeasurementsCsv(csv_file)]
github ARM-software / devlib / devlib / platform / arm.py View on Github external
select_columns = []
            for chan in self.active_channels:
                try:
                    select_columns.append(headings.index(chan.name))
                except ValueError:
                    raise HostError('Channel "{}" is not in {}'.format(chan.name, temp_file))

            with csvwriter(output_file) as writer:
                write_headings = ['{}_{}'.format(c.site, c.kind)
                                  for c in self.active_channels]
                writer.writerow(write_headings)
                for row in reader:
                    write_row = [row[c] for c in select_columns]
                    writer.writerow(write_row)

        return MeasurementsCsv(output_file, self.active_channels, sample_rate_hz=10)
github ARM-software / devlib / devlib / instrument / gem5power.py View on Github external
def get_data(self, outfile):
        active_sites = [c.site for c in self.active_channels]
        with csvwriter(outfile) as writer:
            writer.writerow([c.label for c in self.active_channels]) # headers
            sites_to_match = [self.site_mapping.get(s, s) for s in active_sites]
            for rec, _ in self.target.gem5stats.match_iter(sites_to_match,
                    [self.roi_label], self._base_stats_dump):
                writer.writerow([rec[s] for s in sites_to_match])
        return MeasurementsCsv(outfile, self.active_channels, self.sample_rate_hz)
github ARM-software / devlib / devlib / instrument / netstats / __init__.py View on Github external
def get_data(self, outfile):
        raw_log_file = tempfile.mktemp()
        self.target.dump_logcat(raw_log_file)
        data = extract_netstats(raw_log_file)
        measurements = netstats_to_measurements(data)
        write_measurements_csv(measurements, outfile)
        os.remove(raw_log_file)
        return MeasurementsCsv(outfile, self.active_channels)
github ARM-software / devlib / devlib / derived / fps.py View on Github external
per_frame_fps.name = 'fps'

        frame_count = data.index.size
        if frame_count > 1:
            duration = data.Vsync_time_ns.iloc[-1] - data.Vsync_time_ns.iloc[0]
            fps = (1e9 * frame_count) / float(duration)
        else:
            duration = 0
            fps = 0

        csv_file = self._get_csv_file_name(measurements_csv.path)
        per_frame_fps.to_csv(csv_file, index=False, header=True)

        return [DerivedMetric('fps', fps, 'fps'),
                DerivedMetric('total_frames', frame_count, 'frames'),
                MeasurementsCsv(csv_file)]
github ARM-software / devlib / devlib / derived / fps.py View on Github external
def process(self, measurements_csv):
        if isinstance(measurements_csv, basestring):
            measurements_csv = MeasurementsCsv(measurements_csv)
        if pd is not None:
            return self._process_with_pandas(measurements_csv)
        return self._process_without_pandas(measurements_csv)