blob: 26869b63fa07649fd4282a5bf82396176eda12a4 [file] [log] [blame]
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
import StringIO
import unittest
from measurements import loading_measurement_analyzer
from telemetry.core import util
class LoadingMeasurementAnalyzerUnitTest(unittest.TestCase):
# TODO(tonyg): Remove this backfill when we can assume python 2.7 everywhere.
def assertIn(self, first, second, _=None):
self.assertTrue(first in second,
msg="'%s' not found in '%s'" % (first, second))
def testLoadingProfile(self):
output = StringIO.StringIO()
csv_path = os.path.join(
util.GetChromiumSrcDir(),
'tools', 'perf', 'measurements','test_data', 'loading_profile.csv')
loading_measurement_analyzer.main([csv_path], stdout=output)
output = output.getvalue()
# Get the summary right.
self.assertIn('Total URLs: 9', output)
self.assertIn('Total page load time: 51s', output)
self.assertIn('Average page load time: 5621ms', output)
# Spot check a few samples.
self.assertIn('WTF::IntHash::hash: 1359797948period 1.1%', output)
self.assertIn('WebCore::rangesIntersect: 648335678period 0.5%', output)
self.assertIn('v8::internal::Scanner::Scan: 19668346period 0.0', output)