diff options
-rw-r--r-- | tests/test_baretrace.py | 2 | ||||
-rw-r--r-- | trappy/bare_trace.py | 13 |
2 files changed, 7 insertions, 8 deletions
diff --git a/tests/test_baretrace.py b/tests/test_baretrace.py index 257754d..f1547c3 100644 --- a/tests/test_baretrace.py +++ b/tests/test_baretrace.py @@ -56,7 +56,7 @@ class TestBareTrace(unittest.TestCase): trace.add_parsed_event("pmu_counter", self.dfr[0]) trace.add_parsed_event("load_event", self.dfr[1]) - self.assertEquals(trace.get_duration(), self.dfr[1].index[-1]) + self.assertEquals(trace.get_duration(), self.dfr[1].index[-1] - self.dfr[0].index[0]) def test_bare_trace_get_duration_normalized(self): """BareTrace.get_duration() works if the trace has been normalized""" diff --git a/trappy/bare_trace.py b/trappy/bare_trace.py index a953a60..93a1c6b 100644 --- a/trappy/bare_trace.py +++ b/trappy/bare_trace.py @@ -37,21 +37,20 @@ class BareTrace(object): def get_duration(self): """Returns the largest time value of all classes, returns 0 if the data frames of all classes are empty""" - durations = [] + max_durations = [] + min_durations = [] for trace_class in self.trace_classes: try: - durations.append(trace_class.data_frame.index[-1]) + max_durations.append(trace_class.data_frame.index[-1]) + min_durations.append(trace_class.data_frame.index[0]) except IndexError: pass - if len(durations) == 0: + if len(min_durations) == 0 or len(max_durations) == 0: return 0 - if self.normalized_time: - return max(durations) - else: - return max(durations) - self.basetime + return max(max_durations) - min(min_durations) def get_filters(self, key=""): """Returns an array with the available filters. |