diff options
author | Joel Fernandes <joelaf@google.com> | 2017-04-23 03:52:01 -0700 |
---|---|---|
committer | Joel Fernandes <joelaf@google.com> | 2017-06-02 12:49:36 -0700 |
commit | 45e01409cece3a944aee60f8dc13023a393fede6 (patch) | |
tree | a6b112d85472f680077c960436a852ba3ef5071f | |
parent | ac25b4e59ed854c8ef7139083f5327850ce46973 (diff) | |
download | trappy-45e01409cece3a944aee60f8dc13023a393fede6.tar.gz |
trace: Add support for skipping build of dataframes
For event callback driven scripts, its useful to save time to not build data
frames that aren't going to be used anyway, add a parameter to skip building of
data frames. This saves ~30% of the time an event callback based script takes.
Signed-off-by: Joel Fernandes <joelaf@google.com>
-rw-r--r-- | trappy/bare_trace.py | 5 | ||||
-rw-r--r-- | trappy/ftrace.py | 9 | ||||
-rw-r--r-- | trappy/systrace.py | 8 |
3 files changed, 14 insertions, 8 deletions
diff --git a/trappy/bare_trace.py b/trappy/bare_trace.py index f3fbd58..9787f04 100644 --- a/trappy/bare_trace.py +++ b/trappy/bare_trace.py @@ -27,12 +27,13 @@ class BareTrace(object): """ - def __init__(self, name=""): + def __init__(self, name="", build_df=True): self.name = name self.normalized_time = False self.class_definitions = {} self.trace_classes = [] self.basetime = 0 + self.build_df = build_df def get_duration(self): """Returns the largest time value of all classes, @@ -133,6 +134,8 @@ class BareTrace(object): setattr(self, name, event) def finalize_objects(self): + if not self.build_df: + return for trace_class in self.trace_classes: trace_class.create_dataframe() trace_class.finalize_object() diff --git a/trappy/ftrace.py b/trappy/ftrace.py index 2df91b4..0ef86af 100644 --- a/trappy/ftrace.py +++ b/trappy/ftrace.py @@ -58,8 +58,8 @@ subclassed by FTrace (for parsing FTrace coming from trace-cmd) and SysTrace.""" def __init__(self, name="", normalize_time=True, scope="all", events=[], event_callbacks={}, window=(0, None), - abs_window=(0, None)): - super(GenericFTrace, self).__init__(name) + abs_window=(0, None), build_df=True): + super(GenericFTrace, self).__init__(name, build_df) if not hasattr(self, "needs_raw_parsing"): self.needs_raw_parsing = False @@ -494,14 +494,15 @@ class FTrace(GenericFTrace): def __init__(self, path=".", name="", normalize_time=True, scope="all", events=[], event_callbacks={}, window=(0, None), - abs_window=(0, None)): + abs_window=(0, None), build_df=True): self.trace_path, self.trace_path_raw = self.__process_path(path) self.needs_raw_parsing = True self.__populate_metadata() super(FTrace, self).__init__(name, normalize_time, scope, events, - event_callbacks, window, abs_window) + event_callbacks, window, abs_window, + build_df) def __process_path(self, basepath): """Process the path and return the path to the trace text file""" diff --git a/trappy/systrace.py b/trappy/systrace.py index c619011..c11601d 100644 --- a/trappy/systrace.py +++ b/trappy/systrace.py @@ -51,13 +51,15 @@ class SysTrace(GenericFTrace): def __init__(self, path=".", name="", normalize_time=True, scope="all", events=[], event_callbacks={}, window=(0, None), - abs_window=(0, None)): + abs_window=(0, None), build_df=True): self.trace_path = path super(SysTrace, self).__init__(name, normalize_time, scope, events, - event_callbacks, window, abs_window) - + event_callbacks, window, abs_window, + build_df) + if not build_df: + return try: self._cpus = 1 + self.sched_switch.data_frame["__cpu"].max() except AttributeError: |