Revert 224458 "Enabling MediaStreamInfoBarTest.DenyingCameraDoes..."
[chromium-blink-merge.git] / tools / perf / measurements / loading_measurement_analyzer_unittest.py
blob88401174c0eb89dedc9e6ef9393b17c389177a09
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 import os
5 import StringIO
6 import unittest
8 from measurements import loading_measurement_analyzer
9 from telemetry.core import util
11 class LoadingMeasurementAnalyzerUnitTest(unittest.TestCase):
13 # TODO(tonyg): Remove this backfill when we can assume python 2.7 everywhere.
14 def assertIn(self, first, second, msg=None):
15 self.assertTrue(first in second,
16 msg="'%s' not found in '%s'" % (first, second))
18 def testLoadingProfile(self):
19 output = StringIO.StringIO()
20 csv_path = os.path.join(
21 util.GetChromiumSrcDir(),
22 'tools', 'perf', 'measurements','test_data', 'loading_profile.csv')
23 loading_measurement_analyzer.main([csv_path], stdout=output)
24 output = output.getvalue()
26 # Get the summary right.
27 self.assertIn('Total URLs: 9', output)
28 self.assertIn('Total page load time: 51s', output)
29 self.assertIn('Average page load time: 5621ms', output)
31 # Spot check a few samples.
32 self.assertIn('WTF::IntHash::hash: 1359797948period 1.1%', output)
33 self.assertIn('WebCore::rangesIntersect: 648335678period 0.5%', output)
34 self.assertIn('v8::internal::Scanner::Scan: 19668346period 0.0', output)
36 def testLoadingTimeline(self):
37 output = StringIO.StringIO()
38 csv_path = os.path.join(
39 util.GetChromiumSrcDir(),
40 'tools', 'perf', 'measurements','test_data', 'loading_timeline.csv')
41 loading_measurement_analyzer.main([csv_path], stdout=output)
42 output = output.getvalue()
44 # Get the summary right.
45 self.assertIn('Total URLs: 9', output)
46 self.assertIn('Total page load time: 4s', output)
47 self.assertIn('Average page load time: 422ms', output)
48 self.assertIn('Total CPU time: 4s', output)
49 self.assertIn('Average CPU time: 430ms', output)
51 # Spot check a few samples.
52 self.assertIn('EvaluateScript: 0s 19.0%', output)
53 self.assertIn('ParseHTML: 0s 9.4%', output)
54 self.assertIn('GCEvent: 0s 3.7%', output)