How to use the devlib.derived.DerivedMetric 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 / derived / fps.py View on Github external
def process_raw(filepath, *args):
        metrics = []
        dump = gfxinfo_get_last_dump(filepath)
        seen_stats = False
        for line in dump.split('\n'):
            if seen_stats and not line.strip():
                break
            elif line.startswith('Janky frames:'):
                text = line.split(': ')[-1]
                val_text, pc_text = text.split('(')
                metrics.append(DerivedMetric('janks', numeric(val_text.strip()), 'count'))
                metrics.append(DerivedMetric('janks_pc', numeric(pc_text[:-3]), 'percent'))
            elif ' percentile: ' in line:
                ptile, val_text = line.split(' percentile: ')
                name = 'render_time_{}_ptile'.format(ptile)
                value = numeric(val_text.strip()[:-2])
                metrics.append(DerivedMetric(name, value, 'time_ms'))
            elif line.startswith('Number '):
                name_text, val_text = line.strip().split(': ')
                name = name_text[7:].lower().replace(' ', '_')
                value = numeric(val_text)
                metrics.append(DerivedMetric(name, value, 'count'))
            else:
                continue
            seen_stats = True
        return metrics
github ARM-software / devlib / devlib / derived / fps.py View on Github external
metrics = []
        dump = gfxinfo_get_last_dump(filepath)
        seen_stats = False
        for line in dump.split('\n'):
            if seen_stats and not line.strip():
                break
            elif line.startswith('Janky frames:'):
                text = line.split(': ')[-1]
                val_text, pc_text = text.split('(')
                metrics.append(DerivedMetric('janks', numeric(val_text.strip()), 'count'))
                metrics.append(DerivedMetric('janks_pc', numeric(pc_text[:-3]), 'percent'))
            elif ' percentile: ' in line:
                ptile, val_text = line.split(' percentile: ')
                name = 'render_time_{}_ptile'.format(ptile)
                value = numeric(val_text.strip()[:-2])
                metrics.append(DerivedMetric(name, value, 'time_ms'))
            elif line.startswith('Number '):
                name_text, val_text = line.strip().split(': ')
                name = name_text[7:].lower().replace(' ', '_')
                value = numeric(val_text)
                metrics.append(DerivedMetric(name, value, 'count'))
            else:
                continue
            seen_stats = True
        return metrics
github ARM-software / devlib / devlib / derived / fps.py View on Github external
fps = 1e9 * frame_count / (VSYNC_INTERVAL * total_vsyncs)

            janks = self._calc_janks(filtered_vsyncs_to_compose)
            not_at_vsync = self._calc_not_at_vsync(vsyncs_to_compose)
        else:
            fps = 0
            frame_count = 0
            janks = 0
            not_at_vsync = 0

        janks_pc = 0 if frame_count == 0 else janks * 100 / frame_count

        return [DerivedMetric('fps', fps, 'fps'),
                DerivedMetric('total_frames', frame_count, 'frames'),
                MeasurementsCsv(csv_file),
                DerivedMetric('janks', janks, 'count'),
                DerivedMetric('janks_pc', janks_pc, 'percent'),
                DerivedMetric('missed_vsync', not_at_vsync, 'count')]
github ARM-software / devlib / devlib / derived / energy.py View on Github external
if site in should_calculate_energy:
                        if count == 0:
                            energy_results[site]['start'] = 0
                            energy_results[site]['end'] = 0
                        elif use_timestamp:
                            energy_results[site]['end'] += entry.value * (row_ts - last_ts)
                        else:
                            energy_results[site]['end'] += entry.value * (1 /
                                                           measurements_csv.sample_rate_hz)

        # Calculate final measurements
        derived_measurements = []
        for site in energy_results:
            total_energy = energy_results[site]['end'] - energy_results[site]['start']
            name = '{}_total_energy'.format(site)
            derived_measurements.append(DerivedMetric(name, total_energy, MEASUREMENT_TYPES['energy']))

        for site in power_results:
            power = power_results[site] / (count + 1)  #pylint: disable=undefined-loop-variable
            name = '{}_average_power'.format(site)
            derived_measurements.append(DerivedMetric(name, power, MEASUREMENT_TYPES['power']))

        return derived_measurements
github ARM-software / devlib / devlib / derived / fps.py View on Github external
janks = self._calc_janks(filtered_vsyncs_to_compose)
            not_at_vsync = self._calc_not_at_vsync(vsyncs_to_compose)
        else:
            fps = 0
            frame_count = 0
            janks = 0
            not_at_vsync = 0

        janks_pc = 0 if frame_count == 0 else janks * 100 / frame_count

        return [DerivedMetric('fps', fps, 'fps'),
                DerivedMetric('total_frames', frame_count, 'frames'),
                MeasurementsCsv(csv_file),
                DerivedMetric('janks', janks, 'count'),
                DerivedMetric('janks_pc', janks_pc, 'percent'),
                DerivedMetric('missed_vsync', not_at_vsync, 'count')]
github ARM-software / devlib / devlib / derived / fps.py View on Github external
per_frame_fps.append([pff])

        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 / derived / fps.py View on Github external
per_frame_fps = per_frame_fps[keep_filter]
        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
if total_vsyncs:
                fps = 1e9 * frame_count / (VSYNC_INTERVAL * total_vsyncs)

            janks = self._calc_janks(filtered_vsyncs_to_compose)
            not_at_vsync = self._calc_not_at_vsync(vsyncs_to_compose)
        else:
            fps = 0
            frame_count = 0
            janks = 0
            not_at_vsync = 0

        janks_pc = 0 if frame_count == 0 else janks * 100 / frame_count

        return [DerivedMetric('fps', fps, 'fps'),
                DerivedMetric('total_frames', frame_count, 'frames'),
                MeasurementsCsv(csv_file),
                DerivedMetric('janks', janks, 'count'),
                DerivedMetric('janks_pc', janks_pc, 'percent'),
                DerivedMetric('missed_vsync', not_at_vsync, 'count')]
github ARM-software / devlib / devlib / derived / fps.py View on Github external
frame_count = filtered_vsyncs_to_compose.size

            if total_vsyncs:
                fps = 1e9 * frame_count / (VSYNC_INTERVAL * total_vsyncs)

            janks = self._calc_janks(filtered_vsyncs_to_compose)
            not_at_vsync = self._calc_not_at_vsync(vsyncs_to_compose)
        else:
            fps = 0
            frame_count = 0
            janks = 0
            not_at_vsync = 0

        janks_pc = 0 if frame_count == 0 else janks * 100 / frame_count

        return [DerivedMetric('fps', fps, 'fps'),
                DerivedMetric('total_frames', frame_count, 'frames'),
                MeasurementsCsv(csv_file),
                DerivedMetric('janks', janks, 'count'),
                DerivedMetric('janks_pc', janks_pc, 'percent'),
                DerivedMetric('missed_vsync', not_at_vsync, 'count')]
github ARM-software / devlib / devlib / derived / energy.py View on Github external
energy_results[site]['end'] += entry.value * (row_ts - last_ts)
                        else:
                            energy_results[site]['end'] += entry.value * (1 /
                                                           measurements_csv.sample_rate_hz)

        # Calculate final measurements
        derived_measurements = []
        for site in energy_results:
            total_energy = energy_results[site]['end'] - energy_results[site]['start']
            name = '{}_total_energy'.format(site)
            derived_measurements.append(DerivedMetric(name, total_energy, MEASUREMENT_TYPES['energy']))

        for site in power_results:
            power = power_results[site] / (count + 1)  #pylint: disable=undefined-loop-variable
            name = '{}_average_power'.format(site)
            derived_measurements.append(DerivedMetric(name, power, MEASUREMENT_TYPES['power']))

        return derived_measurements