mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
collector/perf: run simpleperf report-sample in the target if requested
If simpleperf record is called with "-f N", we may want to run "simpleperf report-sample" on the output to dump the periodic records. Let the PerfCollector() run report-sample in the target, similar to how we run report.
This commit is contained in:
parent
4859e818fb
commit
fe2fe3ae04
@ -26,6 +26,7 @@ from devlib.utils.misc import ensure_file_directory_exists as _f
|
|||||||
|
|
||||||
PERF_STAT_COMMAND_TEMPLATE = '{binary} {command} {options} {events} {sleep_cmd} > {outfile} 2>&1 '
|
PERF_STAT_COMMAND_TEMPLATE = '{binary} {command} {options} {events} {sleep_cmd} > {outfile} 2>&1 '
|
||||||
PERF_REPORT_COMMAND_TEMPLATE= '{binary} report {options} -i {datafile} > {outfile} 2>&1 '
|
PERF_REPORT_COMMAND_TEMPLATE= '{binary} report {options} -i {datafile} > {outfile} 2>&1 '
|
||||||
|
PERF_REPORT_SAMPLE_COMMAND_TEMPLATE= '{binary} report-sample {options} -i {datafile} > {outfile} '
|
||||||
PERF_RECORD_COMMAND_TEMPLATE= '{binary} record {options} {events} -o {outfile}'
|
PERF_RECORD_COMMAND_TEMPLATE= '{binary} record {options} {events} -o {outfile}'
|
||||||
|
|
||||||
PERF_DEFAULT_EVENTS = [
|
PERF_DEFAULT_EVENTS = [
|
||||||
@ -90,12 +91,16 @@ class PerfCollector(CollectorBase):
|
|||||||
events=None,
|
events=None,
|
||||||
optionstring=None,
|
optionstring=None,
|
||||||
report_options=None,
|
report_options=None,
|
||||||
|
run_report_sample=False,
|
||||||
|
report_sample_options=None,
|
||||||
labels=None,
|
labels=None,
|
||||||
force_install=False):
|
force_install=False):
|
||||||
super(PerfCollector, self).__init__(target)
|
super(PerfCollector, self).__init__(target)
|
||||||
self.force_install = force_install
|
self.force_install = force_install
|
||||||
self.labels = labels
|
self.labels = labels
|
||||||
self.report_options = report_options
|
self.report_options = report_options
|
||||||
|
self.run_report_sample = run_report_sample
|
||||||
|
self.report_sample_options = report_sample_options
|
||||||
self.output_path = None
|
self.output_path = None
|
||||||
|
|
||||||
# Validate parameters
|
# Validate parameters
|
||||||
@ -138,6 +143,8 @@ class PerfCollector(CollectorBase):
|
|||||||
self.target.remove(filepath)
|
self.target.remove(filepath)
|
||||||
filepath = self._get_target_file(label, 'rpt')
|
filepath = self._get_target_file(label, 'rpt')
|
||||||
self.target.remove(filepath)
|
self.target.remove(filepath)
|
||||||
|
filepath = self._get_target_file(label, 'rptsamples')
|
||||||
|
self.target.remove(filepath)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
for command in self.commands:
|
for command in self.commands:
|
||||||
@ -165,6 +172,9 @@ class PerfCollector(CollectorBase):
|
|||||||
self._wait_for_data_file_write(label, self.output_path)
|
self._wait_for_data_file_write(label, self.output_path)
|
||||||
path = self._pull_target_file_to_host(label, 'rpt', self.output_path)
|
path = self._pull_target_file_to_host(label, 'rpt', self.output_path)
|
||||||
output.append(CollectorOutputEntry(path, 'file'))
|
output.append(CollectorOutputEntry(path, 'file'))
|
||||||
|
if self.run_report_sample:
|
||||||
|
report_samples_path = self._pull_target_file_to_host(label, 'rptsamples', self.output_path)
|
||||||
|
output.append(CollectorOutputEntry(report_samples_path, 'file'))
|
||||||
else:
|
else:
|
||||||
path = self._pull_target_file_to_host(label, 'out', self.output_path)
|
path = self._pull_target_file_to_host(label, 'out', self.output_path)
|
||||||
output.append(CollectorOutputEntry(path, 'file'))
|
output.append(CollectorOutputEntry(path, 'file'))
|
||||||
@ -205,6 +215,13 @@ class PerfCollector(CollectorBase):
|
|||||||
outfile=self._get_target_file(label, 'rpt'))
|
outfile=self._get_target_file(label, 'rpt'))
|
||||||
return command
|
return command
|
||||||
|
|
||||||
|
def _build_perf_report_sample_command(self, label):
|
||||||
|
command = PERF_REPORT_SAMPLE_COMMAND_TEMPLATE.format(binary=self.binary,
|
||||||
|
options=self.report_sample_options or '',
|
||||||
|
datafile=self._get_target_file(label, 'data'),
|
||||||
|
outfile=self._get_target_file(label, 'rptsamples'))
|
||||||
|
return command
|
||||||
|
|
||||||
def _build_perf_record_command(self, options, label):
|
def _build_perf_record_command(self, options, label):
|
||||||
event_string = ' '.join(['-e {}'.format(e) for e in self.events])
|
event_string = ' '.join(['-e {}'.format(e) for e in self.events])
|
||||||
command = PERF_RECORD_COMMAND_TEMPLATE.format(binary=self.binary,
|
command = PERF_RECORD_COMMAND_TEMPLATE.format(binary=self.binary,
|
||||||
@ -237,6 +254,9 @@ class PerfCollector(CollectorBase):
|
|||||||
data_file_finished_writing = True
|
data_file_finished_writing = True
|
||||||
report_command = self._build_perf_report_command(self.report_options, label)
|
report_command = self._build_perf_report_command(self.report_options, label)
|
||||||
self.target.execute(report_command)
|
self.target.execute(report_command)
|
||||||
|
if self.run_report_sample:
|
||||||
|
report_sample_command = self._build_perf_report_sample_command(label)
|
||||||
|
self.target.execute(report_sample_command)
|
||||||
|
|
||||||
def _validate_events(self, events):
|
def _validate_events(self, events):
|
||||||
available_events_string = self.target.execute('{} list | {} cat'.format(self.perf_type, self.target.busybox))
|
available_events_string = self.target.execute('{} list | {} cat'.format(self.perf_type, self.target.busybox))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user