| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 telemetry.value import improvement_direction |
| 5 from telemetry.value import list_of_scalar_values | 6 from telemetry.value import list_of_scalar_values |
| 6 from telemetry.web_perf.metrics import timeline_based_metric | 7 from telemetry.web_perf.metrics import timeline_based_metric |
| 7 | 8 |
| 8 | 9 |
| 9 WRITE_EVENT_NAME = 'Registry::RegisterBlob' | 10 WRITE_EVENT_NAME = 'Registry::RegisterBlob' |
| 10 READ_EVENT_NAME = 'BlobRequest' | 11 READ_EVENT_NAME = 'BlobRequest' |
| 11 | 12 |
| 12 | 13 |
| 13 class BlobTimelineMetric(timeline_based_metric.TimelineBasedMetric): | 14 class BlobTimelineMetric(timeline_based_metric.TimelineBasedMetric): |
| 14 """BlobTimelineMetric reports timing information about blob storage. | 15 """BlobTimelineMetric reports timing information about blob storage. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 59 |
| 59 def _AddWriteResultsInternal(self, events, interactions, results): | 60 def _AddWriteResultsInternal(self, events, interactions, results): |
| 60 writes = [] | 61 writes = [] |
| 61 for event in events: | 62 for event in events: |
| 62 if (self.IsWriteEvent(event) and | 63 if (self.IsWriteEvent(event) and |
| 63 any(self.IsEventInInteraction(event, interaction) | 64 any(self.IsEventInInteraction(event, interaction) |
| 64 for interaction in interactions)): | 65 for interaction in interactions)): |
| 65 writes.append(self.ThreadDurationIfPresent(event)) | 66 writes.append(self.ThreadDurationIfPresent(event)) |
| 66 if writes: | 67 if writes: |
| 67 results.AddValue(list_of_scalar_values.ListOfScalarValues( | 68 results.AddValue(list_of_scalar_values.ListOfScalarValues( |
| 68 page=results.current_page, | 69 page=results.current_page, |
| 69 name='blob-writes', | 70 name='blob-writes', |
| 70 units='ms', | 71 units='ms', |
| 71 values=writes, | 72 values=writes, |
| 72 description='List of durations of blob writes.')) | 73 description='List of durations of blob writes.', |
| 74 improvement_direction=improvement_direction.DOWN)) |
| 73 else: | 75 else: |
| 74 results.AddValue(list_of_scalar_values.ListOfScalarValues( | 76 results.AddValue(list_of_scalar_values.ListOfScalarValues( |
| 75 page=results.current_page, | 77 page=results.current_page, |
| 76 name='blob-writes', | 78 name='blob-writes', |
| 77 units='ms', | 79 units='ms', |
| 78 values=None, | 80 values=None, |
| 79 none_value_reason='No blob write events found for this interaction.')) | 81 none_value_reason='No blob write events found for this interaction.', |
| 82 improvement_direction=improvement_direction.DOWN)) |
| 80 | 83 |
| 81 | 84 |
| 82 def _AddReadResultsInternal(self, events, interactions, results): | 85 def _AddReadResultsInternal(self, events, interactions, results): |
| 83 reads = dict() | 86 reads = dict() |
| 84 for event in events: | 87 for event in events: |
| 85 if (not self.IsReadEvent(event) or | 88 if (not self.IsReadEvent(event) or |
| 86 not any(self.IsEventInInteraction(event, interaction) | 89 not any(self.IsEventInInteraction(event, interaction) |
| 87 for interaction in interactions)): | 90 for interaction in interactions)): |
| 88 continue | 91 continue |
| 89 # Every blob has unique UUID. To get the total time for reading | 92 # Every blob has unique UUID. To get the total time for reading |
| 90 # a blob, we add up the time of all events with the same blob UUID. | 93 # a blob, we add up the time of all events with the same blob UUID. |
| 91 uuid = event.args['uuid'] | 94 uuid = event.args['uuid'] |
| 92 if uuid not in reads: | 95 if uuid not in reads: |
| 93 reads[uuid] = 0 | 96 reads[uuid] = 0 |
| 94 reads[uuid] += self.ThreadDurationIfPresent(event) | 97 reads[uuid] += self.ThreadDurationIfPresent(event) |
| 95 | 98 |
| 96 if reads: | 99 if reads: |
| 97 results.AddValue(list_of_scalar_values.ListOfScalarValues( | 100 results.AddValue(list_of_scalar_values.ListOfScalarValues( |
| 98 page=results.current_page, | 101 page=results.current_page, |
| 99 name='blob-reads', | 102 name='blob-reads', |
| 100 units='ms', | 103 units='ms', |
| 101 values=reads.values(), | 104 values=reads.values(), |
| 102 description='List of read times for blobs.')) | 105 description='List of read times for blobs.', |
| 106 improvement_direction=improvement_direction.DOWN)) |
| 103 else: | 107 else: |
| 104 results.AddValue(list_of_scalar_values.ListOfScalarValues( | 108 results.AddValue(list_of_scalar_values.ListOfScalarValues( |
| 105 page=results.current_page, | 109 page=results.current_page, |
| 106 name='blob-reads', | 110 name='blob-reads', |
| 107 units='ms', | 111 units='ms', |
| 108 values=None, | 112 values=None, |
| 109 none_value_reason='No blob read events found for this interaction.')) | 113 none_value_reason='No blob read events found for this interaction.', |
| 114 improvement_direction=improvement_direction.DOWN)) |
| OLD | NEW |