Upstream version 11.39.266.0
[platform/framework/web/crosswalk.git] / src / tools / perf / measurements / loading_measurement_analyzer_unittest.py
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
7
8 from measurements import loading_measurement_analyzer
9 from telemetry.core import util
10
11 class LoadingMeasurementAnalyzerUnitTest(unittest.TestCase):
12
13   # TODO(tonyg): Remove this backfill when we can assume python 2.7 everywhere.
14   def assertIn(self, first, second, _=None):
15     self.assertTrue(first in second,
16                     msg="'%s' not found in '%s'" % (first, second))
17
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()
25
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)
30
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)