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

Side by Side Diff: chrome/test/functional/devtools_instrumented_objects_check.py

Issue 11054014: Add a test for checking objects reported by DevTools memory instrumentation not allocated by tcmall… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import logging
7 import os
8 import tempfile
9
10 import devtools_test_base
11 import pyauto_functional # Must be imported before pyauto
12 import pyauto
13 import pyauto_utils
14
15
16 class DevToolsInstrumentedObjectsCheck(devtools_test_base.DevToolsTestBase):
17 """Test for checking that all instrumented objects are allocated by tcmalloc.
18
19 This test navigates the browser to a test page, then takes native memory
20 snapshot over remote debugging protocol and prints the number of objects
21 that were counted by the DevTools memory instrumentation and how many of
22 them have not been allocated by tcmalloc. Ideally the latter number should
23 be 0.
24
25 The test starts browser with HEAPPROFILE environment variable to enable
26 tcmalloc heap profiler which is required by the memory instrumentation to
27 check which of the instrumented objects have actually been allocated on the
28 heap.
29
30 The test uses Web Page Replay server as a proxy that allows to replay
31 the same state of the test pages and avoid heavy network traffic on the
32 real web sites. See webpagereplay.ReplayServer documentation to learn how
33 to record new page archives.
34 """
35
36 def setUp(self):
37 # Make sure Chrome is started with tcmalloc heap profiler enabled. Dump
38 # profiles into a temporary directory that will be destroyed when the test
39 # completes.
40 self._tempdir = tempfile.mkdtemp(prefix='devtools-test')
41 os.environ['HEAPPROFILE'] = os.path.join(self._tempdir, 'heap-profile.')
42 # We are not going to use dumped profile so set the interval big enough
dennis_jeffrey 2012/10/04 01:16:33 add period at end of sentence
yurys 2012/10/04 15:07:47 Done.
43 os.environ['HEAP_PROFILE_TIME_INTERVAL'] = str(60 * 60)
dennis_jeffrey 2012/10/04 01:16:33 is there a way to turn off the profile dump rather
yurys 2012/10/04 15:07:47 If the environment variable is omitted then the pr
44 super(DevToolsInstrumentedObjectsCheck, self).setUp()
45
46 def tearDown(self):
47 super(DevToolsInstrumentedObjectsCheck, self).tearDown()
48 del os.environ['HEAPPROFILE']
49 del os.environ['HEAP_PROFILE_TIME_INTERVAL']
50 if self._tempdir:
51 pyauto_utils.RemovePath(self._tempdir)
52
53 def testNytimes(self):
54 self.RunTestWithUrl('http://www.nytimes.com/')
55
56 def testCnn(self):
57 self.RunTestWithUrl('http://www.cnn.com/')
58
59 def testGoogle(self):
60 self.RunTestWithUrl('http://www.google.com/')
61
62 def PrintTestResult(self, hostname, snapshot):
63 total = snapshot.GetProcessPrivateMemorySize()
64 counted_objects = snapshot.GetInstrumentedObjectsCount()
65 counted_unknown_objects = snapshot.GetNumberOfInstrumentedObjectsNotInHeap()
66 logging.info('Got data for: %s, objects count = %d (unknown = %d) ' %
67 (hostname, counted_objects, counted_unknown_objects))
68 graph_name = 'DevTools Instrumented Objects - ' + hostname
69 pyauto_utils.PrintPerfResult(graph_name, 'Reported instrumented objects',
70 counted_objects, 'objects')
71 pyauto_utils.PrintPerfResult(graph_name, 'Not allocated by tcmalloc',
72 counted_unknown_objects, 'objects')
73
74
75 if __name__ == '__main__':
76 pyauto_functional.Main()
OLDNEW
« no previous file with comments | « no previous file | chrome/test/functional/devtools_native_memory_snapshot.py » ('j') | chrome/test/functional/devtools_test_base.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698