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

Unified Diff: tools/telemetry/telemetry/value/histogram.py

Issue 381723002: Refactor Telemetry value system to support AsDict() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Nat's Comments Created 6 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/value/__init__.py ('k') | tools/telemetry/telemetry/value/histogram_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/value/histogram.py
diff --git a/tools/telemetry/telemetry/value/histogram.py b/tools/telemetry/telemetry/value/histogram.py
index 8c4b0e715bbf7e0ebe4243d73d12ada8479e2762..d57f6f57c523980992e9351d94e83d0b1ce5dd3b 100644
--- a/tools/telemetry/telemetry/value/histogram.py
+++ b/tools/telemetry/telemetry/value/histogram.py
@@ -12,6 +12,13 @@ class HistogramValueBucket(object):
self.high = high
self.count = count
+ def AsDict(self):
+ return {
+ 'low': self.low,
+ 'high': self.high,
+ 'count': self.count
+ }
+
def ToJSONString(self):
return '{%s}' % ', '.join([
'"low": %i' % self.low,
@@ -78,6 +85,14 @@ class HistogramValue(value_module.Value):
def GetRepresentativeString(self):
return self.GetBuildbotValue()
+ def GetJSONTypeName(self):
+ return 'histogram'
+
+ def AsDict(self):
+ d = super(HistogramValue, self).AsDict()
+ d['buckets'] = [b.AsDict() for b in self.buckets]
+ return d
+
@classmethod
def MergeLikeValuesFromSamePage(cls, values):
assert len(values) > 0
« no previous file with comments | « tools/telemetry/telemetry/value/__init__.py ('k') | tools/telemetry/telemetry/value/histogram_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698