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

Side by Side Diff: tools/perf/measurements/v8_detached_context_age_in_gc.py

Issue 1917393002: [tools/perf] Reference legacy_page_test module instead of page_test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « tools/perf/measurements/timeline_controller.py ('k') | tools/perf/measurements/v8_gc_times.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 legacy_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
11 11
12 _NAME = 'V8.DetachedContextAgeInGC' 12 _NAME = 'V8.DetachedContextAgeInGC'
13 _UNITS = 'garbage_collections' 13 _UNITS = 'garbage_collections'
14 _DISPLAY_NAME = 'V8_DetachedContextAgeInGC' 14 _DISPLAY_NAME = 'V8_DetachedContextAgeInGC'
15 _TYPE = histogram_util.RENDERER_HISTOGRAM 15 _TYPE = histogram_util.RENDERER_HISTOGRAM
16 _DESCRIPTION = 'Number of GCs needed to collect detached context' 16 _DESCRIPTION = 'Number of GCs needed to collect detached context'
17 17
18 18
19 def _GetMaxDetachedContextAge(tab, data_start): 19 def _GetMaxDetachedContextAge(tab, data_start):
20 data = histogram_util.GetHistogram(_TYPE, _NAME, tab) 20 data = histogram_util.GetHistogram(_TYPE, _NAME, tab)
21 delta = histogram_util.SubtractHistogram(data, data_start) 21 delta = histogram_util.SubtractHistogram(data, data_start)
22 if not 'buckets' in delta: 22 if not 'buckets' in delta:
23 return 23 return
24 buckets = json.loads(delta)['buckets'] 24 buckets = json.loads(delta)['buckets']
25 if buckets: 25 if buckets:
26 return max(x.get('high', x['low']) for x in buckets) 26 return max(x.get('high', x['low']) for x in buckets)
27 27
28 28
29 class V8DetachedContextAgeInGC(page_test.PageTest): 29 class V8DetachedContextAgeInGC(legacy_page_test.LegacyPageTest):
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 self._data_start = histogram_util.GetHistogram(_TYPE, _NAME, tab) 39 self._data_start = histogram_util.GetHistogram(_TYPE, _NAME, tab)
40 40
41 def ValidateAndMeasurePage(self, page, tab, results): 41 def ValidateAndMeasurePage(self, page, tab, results):
42 # Trigger GC to get histogram data. 42 # Trigger GC to get histogram data.
43 # Seven GCs should be enough to collect any detached context. 43 # Seven GCs should be enough to collect any detached context.
44 # If a detached context survives more GCs then there is a leak. 44 # If a detached context survives more GCs then there is a leak.
45 MAX_AGE = 8 45 MAX_AGE = 8
46 for _ in xrange(MAX_AGE): 46 for _ in xrange(MAX_AGE):
47 tab.CollectGarbage() 47 tab.CollectGarbage()
48 value = _GetMaxDetachedContextAge(tab, self._data_start) 48 value = _GetMaxDetachedContextAge(tab, self._data_start)
49 if value is None: 49 if value is None:
50 results.AddValue(skip.SkipValue( 50 results.AddValue(skip.SkipValue(
51 results.current_page, 'No detached contexts')) 51 results.current_page, 'No detached contexts'))
52 else: 52 else:
53 results.AddValue(scalar.ScalarValue( 53 results.AddValue(scalar.ScalarValue(
54 results.current_page, _DISPLAY_NAME, _UNITS, value, 54 results.current_page, _DISPLAY_NAME, _UNITS, value,
55 description=_DESCRIPTION)) 55 description=_DESCRIPTION))
OLDNEW
« no previous file with comments | « tools/perf/measurements/timeline_controller.py ('k') | tools/perf/measurements/v8_gc_times.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698