OLD | NEW |
1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from tracing.value import histogram as histogram_module | 5 from tracing.value import histogram as histogram_module |
6 from tracing.value.diagnostics import all_diagnostics | 6 from tracing.value.diagnostics import all_diagnostics |
7 from tracing.value.diagnostics import diagnostic | 7 from tracing.value.diagnostics import diagnostic |
8 from tracing.value.diagnostics import diagnostic_ref | 8 from tracing.value.diagnostics import diagnostic_ref |
9 | 9 |
10 class HistogramSet(object): | 10 class HistogramSet(object): |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 def GetSharedDiagnosticsOfType(self, typ): | 44 def GetSharedDiagnosticsOfType(self, typ): |
45 return [d for d in self.shared_diagnostics if isinstance(d, typ)] | 45 return [d for d in self.shared_diagnostics if isinstance(d, typ)] |
46 | 46 |
47 def LookupHistogram(self, guid): | 47 def LookupHistogram(self, guid): |
48 return self._histograms_by_guid.get(guid) | 48 return self._histograms_by_guid.get(guid) |
49 | 49 |
50 def LookupDiagnostic(self, guid): | 50 def LookupDiagnostic(self, guid): |
51 return self._shared_diagnostics_by_guid.get(guid) | 51 return self._shared_diagnostics_by_guid.get(guid) |
52 | 52 |
53 def ResolveRelatedHistograms(self): | 53 def ResolveRelatedHistograms(self): |
54 histograms = self | |
55 def HandleDiagnosticMap(dm): | |
56 for diag in dm.itervalues(): | |
57 if isinstance(diag, histogram_module.RelatedHistogramMap): | |
58 diag.Resolve(histograms) | |
59 | |
60 for hist in self: | 54 for hist in self: |
61 hist.diagnostics.ResolveSharedDiagnostics(self) | 55 hist.diagnostics.ResolveSharedDiagnostics(self) |
62 HandleDiagnosticMap(hist.diagnostics) | |
63 for dm in hist.nan_diagnostic_maps: | |
64 HandleDiagnosticMap(dm) | |
65 for hbin in hist.bins: | |
66 for dm in hbin.diagnostic_maps: | |
67 HandleDiagnosticMap(dm) | |
68 | 56 |
69 def __len__(self): | 57 def __len__(self): |
70 return len(self._histograms_by_guid) | 58 return len(self._histograms_by_guid) |
71 | 59 |
72 def __iter__(self): | 60 def __iter__(self): |
73 for hist in self._histograms_by_guid.itervalues(): | 61 for hist in self._histograms_by_guid.itervalues(): |
74 yield hist | 62 yield hist |
75 | 63 |
76 def ImportDicts(self, dicts): | 64 def ImportDicts(self, dicts): |
77 for d in dicts: | 65 for d in dicts: |
(...skipping 12 matching lines...) Expand all Loading... |
90 return dcts | 78 return dcts |
91 | 79 |
92 def ReplaceSharedDiagnostic(self, old_guid, new_diagnostic): | 80 def ReplaceSharedDiagnostic(self, old_guid, new_diagnostic): |
93 if not isinstance(new_diagnostic, diagnostic_ref.DiagnosticRef): | 81 if not isinstance(new_diagnostic, diagnostic_ref.DiagnosticRef): |
94 self._shared_diagnostics_by_guid[new_diagnostic.guid] = new_diagnostic | 82 self._shared_diagnostics_by_guid[new_diagnostic.guid] = new_diagnostic |
95 | 83 |
96 for hist in self: | 84 for hist in self: |
97 for name, diag in hist.diagnostics.iteritems(): | 85 for name, diag in hist.diagnostics.iteritems(): |
98 if diag.has_guid and diag.guid == old_guid: | 86 if diag.has_guid and diag.guid == old_guid: |
99 hist.diagnostics[name] = new_diagnostic | 87 hist.diagnostics[name] = new_diagnostic |
OLD | NEW |