mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
devlib/trace: Refactor trace
to be collector
We now have have multiple `trace` instruments that do not match the description and therefore are moved to have a more suitably named hierarchy.
This commit is contained in:
parent
baa7ad1650
commit
19887de71e
@ -45,10 +45,10 @@ from devlib.derived import DerivedMeasurements, DerivedMetric
|
||||
from devlib.derived.energy import DerivedEnergyMeasurements
|
||||
from devlib.derived.fps import DerivedGfxInfoStats, DerivedSurfaceFlingerStats
|
||||
|
||||
from devlib.trace.ftrace import FtraceCollector
|
||||
from devlib.trace.perf import PerfCollector
|
||||
from devlib.trace.serial_trace import SerialTraceCollector
|
||||
from devlib.trace.dmesg import DmesgCollector
|
||||
from devlib.collector.ftrace import FtraceCollector
|
||||
from devlib.collector.perf import PerfCollector
|
||||
from devlib.collector.serial_trace import SerialTraceCollector
|
||||
from devlib.collector.dmesg import DmesgCollector
|
||||
|
||||
from devlib.host import LocalConnection
|
||||
from devlib.utils.android import AdbConnection
|
||||
|
@ -16,7 +16,7 @@
|
||||
import logging
|
||||
|
||||
|
||||
class TraceCollector(object):
|
||||
class CollectorBase(object):
|
||||
|
||||
def __init__(self, target):
|
||||
self.target = target
|
@ -18,7 +18,7 @@ import re
|
||||
from itertools import takewhile
|
||||
from datetime import timedelta
|
||||
|
||||
from devlib.trace import TraceCollector
|
||||
from devlib.collector import CollectorBase
|
||||
|
||||
|
||||
class KernelLogEntry(object):
|
||||
@ -121,7 +121,7 @@ class KernelLogEntry(object):
|
||||
)
|
||||
|
||||
|
||||
class DmesgCollector(TraceCollector):
|
||||
class DmesgCollector(CollectorBase):
|
||||
"""
|
||||
Dmesg output collector.
|
||||
|
@ -23,7 +23,7 @@ import sys
|
||||
import contextlib
|
||||
from pipes import quote
|
||||
|
||||
from devlib.trace import TraceCollector
|
||||
from devlib.collector import CollectorBase
|
||||
from devlib.host import PACKAGE_BIN_DIRECTORY
|
||||
from devlib.exception import TargetStableError, HostError
|
||||
from devlib.utils.misc import check_output, which, memoized
|
||||
@ -50,7 +50,7 @@ TIMEOUT = 180
|
||||
CPU_RE = re.compile(r' Function \(CPU([0-9]+)\)')
|
||||
STATS_RE = re.compile(r'([^ ]*) +([0-9]+) +([0-9.]+) us +([0-9.]+) us +([0-9.]+) us')
|
||||
|
||||
class FtraceCollector(TraceCollector):
|
||||
class FtraceCollector(CollectorBase):
|
||||
|
||||
# pylint: disable=too-many-locals,too-many-branches,too-many-statements
|
||||
def __init__(self, target,
|
@ -16,10 +16,10 @@
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from devlib.trace import TraceCollector
|
||||
from devlib.collector import CollectorBase
|
||||
from devlib.utils.android import LogcatMonitor
|
||||
|
||||
class LogcatCollector(TraceCollector):
|
||||
class LogcatCollector(CollectorBase):
|
||||
|
||||
def __init__(self, target, regexps=None):
|
||||
super(LogcatCollector, self).__init__(target)
|
@ -19,13 +19,13 @@ import time
|
||||
from past.builtins import basestring, zip
|
||||
|
||||
from devlib.host import PACKAGE_BIN_DIRECTORY
|
||||
from devlib.trace import TraceCollector
|
||||
from devlib.collector import CollectorBase
|
||||
from devlib.utils.misc import ensure_file_directory_exists as _f
|
||||
|
||||
|
||||
PERF_COMMAND_TEMPLATE = '{binary} {command} {options} {events} sleep 1000 > {outfile} 2>&1 '
|
||||
PERF_REPORT_COMMAND_TEMPLATE= '{binary} report {options} -i {datafile} > {outfile} 2>&1 '
|
||||
PERF_RECORD_COMMAND_TEMPLATE= '{binary} record {options} {events} -o {outfile}'
|
||||
PERF_RECORD_COMMAND_TEMPLATE= '{binary} record {options} {events} -o {outfile}'
|
||||
|
||||
PERF_DEFAULT_EVENTS = [
|
||||
'cpu-migrations',
|
||||
@ -42,7 +42,7 @@ SIMPLEPERF_DEFAULT_EVENTS = [
|
||||
|
||||
DEFAULT_EVENTS = {'perf':PERF_DEFAULT_EVENTS, 'simpleperf':SIMPLEPERF_DEFAULT_EVENTS}
|
||||
|
||||
class PerfCollector(TraceCollector):
|
||||
class PerfCollector(CollectorBase):
|
||||
"""
|
||||
Perf is a Linux profiling with performance counters.
|
||||
Simpleperf is an Android profiling tool with performance counters.
|
||||
@ -82,7 +82,7 @@ class PerfCollector(TraceCollector):
|
||||
man perf-stat
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
def __init__(self,
|
||||
target,
|
||||
perf_type='perf',
|
||||
command='stat',
|
||||
@ -216,7 +216,7 @@ class PerfCollector(TraceCollector):
|
||||
current_tries += 1
|
||||
else:
|
||||
if current_tries >= max_tries:
|
||||
self.logger.warning('''writing {}.data file took longer than expected,
|
||||
self.logger.warning('''writing {}.data file took longer than expected,
|
||||
file may not have written correctly'''.format(label))
|
||||
data_file_finished_writing = True
|
||||
report_command = self._build_perf_report_command(self.report_options, label)
|
||||
@ -229,7 +229,7 @@ class PerfCollector(TraceCollector):
|
||||
if available_event == '':
|
||||
continue
|
||||
if 'OR' in available_event:
|
||||
available_events.append(available_event.split('OR')[1])
|
||||
available_events.append(available_event.split('OR')[1])
|
||||
available_events[available_events.index(available_event)] = available_event.split()[0].strip()
|
||||
# Raw hex event codes can also be passed in that do not appear on perf/simpleperf list, prefixed with 'r'
|
||||
raw_event_code_regex = re.compile(r"^r(0x|0X)?[A-Fa-f0-9]+$")
|
@ -19,7 +19,7 @@ import sys
|
||||
import threading
|
||||
import time
|
||||
|
||||
from devlib.trace import TraceCollector
|
||||
from devlib.collector import BaseCollector
|
||||
from devlib.exception import WorkerThreadError
|
||||
|
||||
|
||||
@ -66,7 +66,7 @@ class ScreenCapturePoller(threading.Thread):
|
||||
self.target.capture_screen(os.path.join(self.output_path, "screencap_{ts}.png"))
|
||||
|
||||
|
||||
class ScreenCaptureCollector(TraceCollector):
|
||||
class ScreenCaptureCollector(BaseCollector):
|
||||
|
||||
def __init__(self, target, output_path=None, period=None):
|
||||
super(ScreenCaptureCollector, self).__init__(target)
|
@ -17,11 +17,11 @@ import shutil
|
||||
from tempfile import NamedTemporaryFile
|
||||
from pexpect.exceptions import TIMEOUT
|
||||
|
||||
from devlib.trace import TraceCollector
|
||||
from devlib.collector import CollectorBase
|
||||
from devlib.utils.serial_port import get_connection
|
||||
|
||||
|
||||
class SerialTraceCollector(TraceCollector):
|
||||
class SerialTraceCollector(CollectorBase):
|
||||
|
||||
@property
|
||||
def collecting(self):
|
@ -20,7 +20,7 @@ from shutil import copyfile
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
from devlib.exception import TargetStableError, HostError
|
||||
from devlib.trace import TraceCollector
|
||||
from devlib.collector import CollectorBase
|
||||
import devlib.utils.android
|
||||
from devlib.utils.misc import memoized
|
||||
|
||||
@ -33,7 +33,7 @@ DEFAULT_CATEGORIES = [
|
||||
'idle'
|
||||
]
|
||||
|
||||
class SystraceCollector(TraceCollector):
|
||||
class SystraceCollector(CollectorBase):
|
||||
"""
|
||||
A trace collector based on Systrace
|
||||
|
Loading…
x
Reference in New Issue
Block a user