From edc53078c056df33a9872fd170d6a66c2acd82d8 Mon Sep 17 00:00:00 2001 From: Javi Merino Date: Thu, 31 Mar 2016 18:07:52 +0100 Subject: [PATCH 1/3] libs/utils/trace: factor out trace class invocation trappy.SysTrace() and trappy.FTrace() accept the same arguments (and we want that to continue to be). Factor out the invocation of the class below the condition to avoid repeating the arguments. --- libs/utils/trace.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libs/utils/trace.py b/libs/utils/trace.py index 961854a11..a19f026d8 100644 --- a/libs/utils/trace.py +++ b/libs/utils/trace.py @@ -94,17 +94,16 @@ class Trace(object): logging.debug("Parsing events: %s", self.events) if trace_format.upper() == 'SYSTRACE' or path.endswith('html'): logging.info('Parsing SysTrace format...') - self.ftrace = trappy.SysTrace(path, scope="custom", - events=self.events, - window=window) + trace_class = trappy.SysTrace self.trace_format = 'SysTrace' elif trace_format.upper() == 'FTRACE': logging.info('Parsing FTrace format...') - self.ftrace = trappy.FTrace(path, scope="custom", - events=self.events, - window=window) + trace_class = trappy.FTrace self.trace_format = 'FTrace' + self.ftrace = trace_class(path, scope="custom", events=self.events, + window=window) + # Check for events available on the parsed trace self.__checkAvailableEvents() if len(self.available_events) == 0: -- GitLab From d02408964a1d1042b99f51ba01989e8cf02478fa Mon Sep 17 00:00:00 2001 From: Javi Merino Date: Thu, 31 Mar 2016 18:10:54 +0100 Subject: [PATCH 2/3] libs/utils/trace: provide a meaningful error if we don't understand the trace format Up until 34f5d28c5ef4 ("libs/utils/trace: add support for systrace trace format") we treated every trace path as a file captured with trace-cmd, so we always parsed it with with trappy.FTrace and let it fail if it wasn't. Now that we have support for SysTrace as well, we barf with a weird error message if we don't understand the trace_format. Raise an exception instead to make it easier to understand what is going wrong. --- libs/utils/trace.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/utils/trace.py b/libs/utils/trace.py index a19f026d8..0333219f8 100644 --- a/libs/utils/trace.py +++ b/libs/utils/trace.py @@ -100,6 +100,8 @@ class Trace(object): logging.info('Parsing FTrace format...') trace_class = trappy.FTrace self.trace_format = 'FTrace' + else: + raise ValueError("Unknown trace format {}".format(trace_format)) self.ftrace = trace_class(path, scope="custom", events=self.events, window=window) -- GitLab From b4ab05a5cc9630963cdfafeab214dcf1661167c7 Mon Sep 17 00:00:00 2001 From: Javi Merino Date: Thu, 31 Mar 2016 11:24:07 +0100 Subject: [PATCH 3/3] libs/utils/trace: add support for normalize_time Pass normalize_time down to trappy. Sometimes it's useful to have the same time between kernelshark and trappy. Trappy supports this with normalize_time but the Trace class doesn't allow you to specify it. Let Trace accept this parameter and pass it down to trappy. close #57 --- libs/utils/trace.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libs/utils/trace.py b/libs/utils/trace.py index 0333219f8..510b3e97b 100644 --- a/libs/utils/trace.py +++ b/libs/utils/trace.py @@ -33,6 +33,7 @@ class Trace(object): def __init__(self, platform, datadir, events, tasks=None, window=(0,None), + normalize_time=True, trace_format='FTrace'): # The platform used to run the experiments @@ -76,7 +77,7 @@ class Trace(object): self.datadir = datadir self.__registerTraceEvents(events) - self.__parseTrace(datadir, tasks, window, trace_format) + self.__parseTrace(datadir, tasks, window, normalize_time, trace_format) self.__computeTimeSpan() def __registerTraceEvents(self, events): @@ -89,7 +90,7 @@ class Trace(object): raise ValueError('Events must be a string or a list of strings') - def __parseTrace(self, path, tasks, window, trace_format): + def __parseTrace(self, path, tasks, window, normalize_time, trace_format): logging.debug('Loading [sched] events from trace in [%s]...', path) logging.debug("Parsing events: %s", self.events) if trace_format.upper() == 'SYSTRACE' or path.endswith('html'): @@ -104,7 +105,7 @@ class Trace(object): raise ValueError("Unknown trace format {}".format(trace_format)) self.ftrace = trace_class(path, scope="custom", events=self.events, - window=window) + window=window, normalize_time=normalize_time) # Check for events available on the parsed trace self.__checkAvailableEvents() -- GitLab