diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/utils/trace.py | 19 | ||||
-rw-r--r-- | libs/utils/trace_callback.py | 25 |
2 files changed, 42 insertions, 2 deletions
diff --git a/libs/utils/trace.py b/libs/utils/trace.py index ada8db4..d3cabed 100644 --- a/libs/utils/trace.py +++ b/libs/utils/trace.py @@ -78,7 +78,9 @@ class Trace(object): normalize_time=True, trace_format='FTrace', plots_dir=None, - plots_prefix=''): + plots_prefix='', + event_callbacks={}, + build_df=True): # The platform used to run the experiments self.platform = platform @@ -108,6 +110,10 @@ class Trace(object): # List of events required by user self.events = [] + # Stuff for event callback support + self.event_callbacks = event_callbacks + self.build_df = build_df + # List of events available in the parsed trace self.available_events = [] @@ -135,6 +141,11 @@ class Trace(object): self.__registerTraceEvents(events) self.__parseTrace(data_dir, tasks, window, normalize_time, trace_format) + + if not self.build_df: + self._log.info('Data frames not built for the trace') + return + self.__computeTimeSpan() # Minimum and Maximum x_time to use for all plots @@ -242,7 +253,9 @@ class Trace(object): raise ValueError("Unknown trace format {}".format(trace_format)) self.ftrace = trace_class(path, scope="custom", events=self.events, - window=window, normalize_time=normalize_time) + window=window, normalize_time=normalize_time, + event_callbacks=self.event_callbacks, + build_df=self.build_df) # Load Functions profiling data has_function_stats = self._loadFunctionsStats(path) @@ -253,6 +266,8 @@ class Trace(object): if has_function_stats: self._log.info('Trace contains only functions stats') return + elif not self.build_df: + return raise ValueError('The trace does not contain useful events ' 'nor function stats') diff --git a/libs/utils/trace_callback.py b/libs/utils/trace_callback.py new file mode 100644 index 0000000..6115adf --- /dev/null +++ b/libs/utils/trace_callback.py @@ -0,0 +1,25 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2017, Google and contributors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +from trace import Trace + +class TraceCallback(object): + """ + The TraceCallbacks object which is used for event-driven trace analysis + """ + def __init__(self, trace_path, callbacks): + self.trace_obj = Trace(None, trace_path, callbacks.keys(), event_callbacks=callbacks, build_df=False); |