Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Unified Diff: tools/telemetry/telemetry/core/timeline/counter.py

Issue 19790005: Reland [telemetry] Timeline model cleanups (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/telemetry/telemetry/core/timeline/bounds.py ('k') | tools/telemetry/telemetry/core/timeline/event.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/timeline/counter.py
diff --git a/tools/telemetry/telemetry/core/timeline/tracing/counter.py b/tools/telemetry/telemetry/core/timeline/counter.py
similarity index 50%
rename from tools/telemetry/telemetry/core/timeline/tracing/counter.py
rename to tools/telemetry/telemetry/core/timeline/counter.py
index 33f5e86b1b99414a3bc162ddc83ed8ca1b9e077f..f21f5162fe487a3979ba96c3816ca9919993c1b4 100644
--- a/tools/telemetry/telemetry/core/timeline/tracing/counter.py
+++ b/tools/telemetry/telemetry/core/timeline/counter.py
@@ -2,32 +2,56 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-class Counter(object):
- ''' Stores all the samples for a given counter.
- '''
+import telemetry.core.timeline.event_container as event_container
+
+# Doesn't inherit from TimelineEvent because its only a temporary wrapper of a
+# counter sample into an event. During stable operation, the samples are stored
+# a dense array of values rather than in the long-form done by an Event.
+class CounterSample(object):
+ def __init__(self, counter, sample_index):
+ self._counter = counter
+ self._sample_index = sample_index
+
+ @property
+ def name(self):
+ return None
+
+ @property
+ def start(self):
+ return self._counter.timestamps[self._sample_index]
+
+ @start.setter
+ def start(self, start):
+ self._counter.timestamps[self._sample_index] = start
+
+ @property
+ def duration(self):
+ return 0
+
+ @property
+ def end(self):
+ return self.start
+
+
+class Counter(event_container.TimelineEventContainer):
+ """ Stores all the samples for a given counter.
+ """
def __init__(self, parent, category, name):
- self.parent = parent
- self.full_name = category + '.' + name
+ super(Counter, self).__init__(name, parent)
self.category = category
- self.name = name
+ self.full_name = category + '.' + name
self.samples = []
self.timestamps = []
self.series_names = []
self.totals = []
self.max_total = 0
- self._bounds = None
- @property
- def min_timestamp(self):
- if not self._bounds:
- self.UpdateBounds()
- return self._bounds[0]
+ def IterChildContainers(self):
+ return iter([])
- @property
- def max_timestamp(self):
- if not self._bounds:
- self.UpdateBounds()
- return self._bounds[1]
+ def IterEventsInThisContainer(self):
+ for i in range(len(self.timestamps)):
+ yield CounterSample(self, i)
@property
def num_series(self):
@@ -37,7 +61,7 @@ class Counter(object):
def num_samples(self):
return len(self.timestamps)
- def UpdateBounds(self):
+ def FinalizeImport(self):
if self.num_series * self.num_samples != len(self.samples):
raise ValueError(
'Length of samples must be a multiple of length of timestamps.')
@@ -47,8 +71,6 @@ class Counter(object):
if not len(self.samples):
return
- self._bounds = (self.timestamps[0], self.timestamps[-1])
-
max_total = None
for i in xrange(self.num_samples):
total = 0
@@ -58,4 +80,3 @@ class Counter(object):
if max_total is None or total > max_total:
max_total = total
self.max_total = max_total
-
« no previous file with comments | « tools/telemetry/telemetry/core/timeline/bounds.py ('k') | tools/telemetry/telemetry/core/timeline/event.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698