| 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 import json | 5 import json |
| 6 | 6 |
| 7 from telemetry.page import page_test | 7 from telemetry.page import page_test |
| 8 from telemetry.value import histogram_util | 8 from telemetry.value import histogram_util |
| 9 from telemetry.value import scalar | 9 from telemetry.value import scalar |
| 10 from telemetry.value import skip | 10 from telemetry.value import skip |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 class V8DetachedContextAgeInGC(page_test.PageTest): | 29 class V8DetachedContextAgeInGC(page_test.PageTest): |
| 30 | 30 |
| 31 def __init__(self): | 31 def __init__(self): |
| 32 super(V8DetachedContextAgeInGC, self).__init__() | 32 super(V8DetachedContextAgeInGC, self).__init__() |
| 33 self._data_start = None | 33 self._data_start = None |
| 34 | 34 |
| 35 def CustomizeBrowserOptions(self, options): | 35 def CustomizeBrowserOptions(self, options): |
| 36 options.AppendExtraBrowserArgs(['--enable-stats-collection-bindings']) | 36 options.AppendExtraBrowserArgs(['--enable-stats-collection-bindings']) |
| 37 | 37 |
| 38 def DidNavigateToPage(self, page, tab): | 38 def DidNavigateToPage(self, page, tab): |
| 39 del page # unused |
| 39 self._data_start = histogram_util.GetHistogram(_TYPE, _NAME, tab) | 40 self._data_start = histogram_util.GetHistogram(_TYPE, _NAME, tab) |
| 40 | 41 |
| 41 def ValidateAndMeasurePage(self, page, tab, results): | 42 def ValidateAndMeasurePage(self, page, tab, results): |
| 43 del page # unused |
| 42 # Trigger GC to get histogram data. | 44 # Trigger GC to get histogram data. |
| 43 # Seven GCs should be enough to collect any detached context. | 45 # Seven GCs should be enough to collect any detached context. |
| 44 # If a detached context survives more GCs then there is a leak. | 46 # If a detached context survives more GCs then there is a leak. |
| 45 MAX_AGE = 8 | 47 MAX_AGE = 8 |
| 46 for _ in xrange(MAX_AGE): | 48 for _ in xrange(MAX_AGE): |
| 47 tab.CollectGarbage() | 49 tab.CollectGarbage() |
| 48 value = _GetMaxDetachedContextAge(tab, self._data_start) | 50 value = _GetMaxDetachedContextAge(tab, self._data_start) |
| 49 if value is None: | 51 if value is None: |
| 50 results.AddValue(skip.SkipValue( | 52 results.AddValue(skip.SkipValue( |
| 51 results.current_page, 'No detached contexts')) | 53 results.current_page, 'No detached contexts')) |
| 52 else: | 54 else: |
| 53 results.AddValue(scalar.ScalarValue( | 55 results.AddValue(scalar.ScalarValue( |
| 54 results.current_page, _DISPLAY_NAME, _UNITS, value, | 56 results.current_page, _DISPLAY_NAME, _UNITS, value, |
| 55 description=_DESCRIPTION)) | 57 description=_DESCRIPTION)) |
| OLD | NEW |