summaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authornduca@chromium.org <nduca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-10 19:43:06 +0000
committernduca@chromium.org <nduca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-10 19:43:06 +0000
commitf884f3082df890779c4783e107c85959bf2b0dd4 (patch)
tree290b3792afd2fa7477d1c2a42af656e898f6d083 /tools/perf
parent1044d59fd223c0bbe4616860ae9603c1d53f8437 (diff)
downloadchromium_src-f884f3082df890779c4783e107c85959bf2b0dd4.zip
chromium_src-f884f3082df890779c4783e107c85959bf2b0dd4.tar.gz
chromium_src-f884f3082df890779c4783e107c85959bf2b0dd4.tar.bz2
Benchmark to characterize main thread usage during load
This uses inspector timeline and telemetry to get an estimate of time consumption during page load. NOTRY=True Review URL: https://chromiumcodereview.appspot.com/11791043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176132 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/perf_tools/loading_benchmark.py36
-rw-r--r--tools/perf/perf_tools/loading_benchmark_unittest.py21
2 files changed, 57 insertions, 0 deletions
diff --git a/tools/perf/perf_tools/loading_benchmark.py b/tools/perf/perf_tools/loading_benchmark.py
new file mode 100644
index 0000000..61b6a01
--- /dev/null
+++ b/tools/perf/perf_tools/loading_benchmark.py
@@ -0,0 +1,36 @@
+# Copyright (c) 2012 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 collections
+
+from telemetry import multi_page_benchmark
+
+class LoadingBenchmark(multi_page_benchmark.MultiPageBenchmark):
+ @property
+ def results_are_the_same_on_every_page(self):
+ return False
+
+ def WillNavigateToPage(self, page, tab):
+ tab.timeline.Start()
+
+ def MeasurePage(self, page, tab, results):
+ # In current telemetry tests, all tests wait for DocumentComplete state.
+ #
+ # TODO(nduca): when crbug.com/168431 is fixed, modify the page sets to
+ # recognize loading as a toplevel action.
+ tab.timeline.Stop()
+
+ events = tab.timeline.timeline_model.GetAllEvents()
+
+ events_by_name = collections.defaultdict(list)
+ for e in events:
+ events_by_name[e.name].append(e)
+
+ for key, group in events_by_name.items():
+ times = [e.self_time_ms for e in group]
+ total = sum(times)
+ biggest_jank = max(times)
+ results.Add(key, 'ms', total)
+ results.Add(key + '_max', 'ms', biggest_jank)
+ results.Add(key + '_avg', 'ms', total / len(times))
diff --git a/tools/perf/perf_tools/loading_benchmark_unittest.py b/tools/perf/perf_tools/loading_benchmark_unittest.py
new file mode 100644
index 0000000..4ac441f
--- /dev/null
+++ b/tools/perf/perf_tools/loading_benchmark_unittest.py
@@ -0,0 +1,21 @@
+# Copyright (c) 2012 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.
+from telemetry import multi_page_benchmark_unittest_base
+from perf_tools import loading_benchmark
+
+class SmoothnessBenchmarkUnitTest(
+ multi_page_benchmark_unittest_base.MultiPageBenchmarkUnitTestBase):
+
+ def testBasicFunctionality(self):
+ ps = self.CreatePageSetFromFileInUnittestDataDir('blank.html')
+
+ benchmark = loading_benchmark.LoadingBenchmark()
+ all_results = self.RunBenchmark(benchmark, ps)
+
+ self.assertEqual(0, len(all_results.page_failures))
+ self.assertEqual(1, len(all_results.page_results))
+
+ results0 = all_results.page_results[0]
+ self.assertTrue(results0['Layout'].value > 0)
+ self.assertTrue(results0['Paint'].value > 0)