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

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

Issue 930333002: [telemetry] Add new measurement that counts number of GCs needed to free V8 context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
(Empty)
1 # Copyright 2012 The Chromium Authors. All rights reserved.
Sami 2015/02/17 17:14:06 year += 3 :)
ulan 2015/02/18 10:35:56 Done.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import json
6 from telemetry.page import page_test
7 from telemetry.value import histogram
8 from telemetry.value import histogram_util
9 from telemetry.value import scalar
10
11 _NAME = 'V8.DetachedContextAgeInGC'
12 _UNITS = 'garbage_collections'
13 _DISPLAY_NAME = 'V8_DetachedContextAgeInGC'
14 _TYPE = histogram_util.RENDERER_HISTOGRAM
15 _DESCRIPTION = 'Number of GCs needed to collect detached context'
16
Sami 2015/02/17 17:14:06 nit: add an extra blank line here.
ulan 2015/02/18 10:35:56 Done.
17 def _MaxDetachedContextAge(histogram_data):
18 if not 'buckets' in histogram_data:
19 return 0
20 buckets = json.loads(histogram_data)['buckets']
21 return max(map(lambda x: x['high'], buckets)) if buckets else 0
Sami 2015/02/17 17:14:06 nit: max(x['high'] for x in buckets) works too.
ulan 2015/02/18 10:35:55 Done.
22
23
24 class V8DetachedContextAgeInGC(page_test.PageTest):
Sami 2015/02/17 17:14:06 Could you please add a unit test for this too?
ulan 2015/02/18 10:35:56 Done.
25 def __init__(self):
26 super(V8DetachedContextAgeInGC, self).__init__('RunPageInteractions')
27 self._data_start = None
28
29 def CustomizeBrowserOptions(self, options):
30 options.AppendExtraBrowserArgs(['--enable-stats-collection-bindings'])
31
32 def DidNavigateToPage(self, page, tab):
33 self._data_start = histogram_util.GetHistogram(_TYPE, _NAME, tab)
34
35 def ValidateAndMeasurePage(self, page, tab, results):
36 # Trigger GC to get histogram data.
37 # Seven GCs should be enough to collect any detached context.
38 # If a detached context survives more GCs then there is a leak.
39 for _ in xrange(8):
40 tab.CollectGarbage()
41 data = histogram_util.GetHistogram(_TYPE, _NAME, tab)
42 delta = histogram_util.SubtractHistogram(data, self._data_start)
43 value = _MaxDetachedContextAge(delta)
44 results.AddValue(scalar.ScalarValue(
45 results.current_page, _DISPLAY_NAME, _UNITS, value,
46 description=_DESCRIPTION))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698