summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhartmanng@chromium.org <hartmanng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-21 20:11:52 +0000
committerhartmanng@chromium.org <hartmanng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-21 20:11:52 +0000
commita5b131332508632b49d5f452bbbdf7ce1ceeeaa0 (patch)
tree5fbf2867377e72f5d74ef08b38b05aa85ccd8db9
parentc73b501991379a6d2ef827dd2e09b0c2074966d2 (diff)
downloadchromium_src-a5b131332508632b49d5f452bbbdf7ce1ceeeaa0.zip
chromium_src-a5b131332508632b49d5f452bbbdf7ce1ceeeaa0.tar.gz
chromium_src-a5b131332508632b49d5f452bbbdf7ce1ceeeaa0.tar.bz2
Refactoring benchmarks for perf bot efficiency.
See also: https://codereview.chromium.org/11316017/ (separate patch to move scrolling logic into scrolling_interaction.py as discussed in https://codereview.chromium.org/11366197/#msg2) BUG=160149 Review URL: https://chromiumcodereview.appspot.com/11366197 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169110 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--tools/perf/perf_tools/first_paint_time_benchmark.py28
-rw-r--r--tools/perf/perf_tools/first_paint_time_benchmark_unittest.py23
-rw-r--r--tools/perf/perf_tools/scrolling_benchmark.py91
-rw-r--r--tools/perf/perf_tools/smoothness_benchmark.py136
-rw-r--r--tools/perf/perf_tools/smoothness_benchmark_unittest.py (renamed from tools/perf/perf_tools/scrolling_benchmark_unittest.py)29
-rw-r--r--tools/perf/perf_tools/texture_upload_benchmark.py27
-rw-r--r--tools/telemetry/telemetry/multi_page_benchmark_unittest_base.py1
7 files changed, 162 insertions, 173 deletions
diff --git a/tools/perf/perf_tools/first_paint_time_benchmark.py b/tools/perf/perf_tools/first_paint_time_benchmark.py
deleted file mode 100644
index b781fee..0000000
--- a/tools/perf/perf_tools/first_paint_time_benchmark.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# 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.
-
-# The test takes a list of URLs through stdin and prints results in CSV format.
-# Example: python run_scroll_test.py < data/urls.txt > test_results.csv
-from telemetry import multi_page_benchmark
-from telemetry import util
-
-class FirstPaintTimeBenchmark(multi_page_benchmark.MultiPageBenchmark):
- def MeasurePage(self, _, tab, results):
- if tab.browser.is_content_shell:
- results.Add('first_paint', 'seconds', 'unsupported')
- return
-
- tab.runtime.Execute("""
- window.__rafFired = false;
- window.webkitRequestAnimationFrame(function() {
- window.__rafFired = true;
- });
- """)
- util.WaitFor(lambda: tab.runtime.Evaluate('window.__rafFired'), 60)
-
- first_paint_secs = tab.runtime.Evaluate(
- 'window.chrome.loadTimes().firstPaintTime - ' +
- 'window.chrome.loadTimes().requestTime')
-
- results.Add('first_paint', 'seconds', round(first_paint_secs, 1))
diff --git a/tools/perf/perf_tools/first_paint_time_benchmark_unittest.py b/tools/perf/perf_tools/first_paint_time_benchmark_unittest.py
deleted file mode 100644
index a4e8869..0000000
--- a/tools/perf/perf_tools/first_paint_time_benchmark_unittest.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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 first_paint_time_benchmark
-
-class FirstPaintTimeBenchmarkUnitTest(
- multi_page_benchmark_unittest_base.MultiPageBenchmarkUnitTestBase):
-
- def testFirstPaintTimeMeasurement(self):
- ps = self.CreatePageSetFromFileInUnittestDataDir('scrollable_page.html')
-
- benchmark = first_paint_time_benchmark.FirstPaintTimeBenchmark()
- 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]
- if results0['first_paint'] == 'unsupported':
- # This test can't run on content_shell.
- return
- self.assertTrue(results0['first_paint'] > 0)
diff --git a/tools/perf/perf_tools/scrolling_benchmark.py b/tools/perf/perf_tools/scrolling_benchmark.py
index 73670332..cc3ddad 100644
--- a/tools/perf/perf_tools/scrolling_benchmark.py
+++ b/tools/perf/perf_tools/scrolling_benchmark.py
@@ -1,93 +1,8 @@
# 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
+from perf_tools import smoothness_benchmark
-class DidNotScrollException(multi_page_benchmark.MeasurementFailure):
+class ScrollingBenchmark(smoothness_benchmark.SmoothnessBenchmark):
def __init__(self):
- super(DidNotScrollException, self).__init__('Page did not scroll')
-
-def GetOrZero(stat, rendering_stats_deltas):
- if stat in rendering_stats_deltas:
- return rendering_stats_deltas[stat]
- return 0
-
-def DivideIfPossibleOrZero(numerator, denominator):
- if denominator == 0:
- return 0
- return numerator / denominator
-
-def CalcScrollResults(rendering_stats_deltas, results):
- num_frames_sent_to_screen = rendering_stats_deltas['numFramesSentToScreen']
-
- mean_frame_time_seconds = (
- rendering_stats_deltas['totalTimeInSeconds'] /
- float(num_frames_sent_to_screen))
-
- dropped_percent = (
- rendering_stats_deltas['droppedFrameCount'] /
- float(num_frames_sent_to_screen))
-
-
- totalPaintTime = GetOrZero('totalPaintTimeInSeconds',
- rendering_stats_deltas)
-
- totalRasterizeTime = GetOrZero('totalRasterizeTimeInSeconds',
- rendering_stats_deltas)
-
- totalPixelsPainted = GetOrZero('totalPixelsPainted',
- rendering_stats_deltas)
-
- totalPixelsRasterized = GetOrZero('totalPixelsRasterized',
- rendering_stats_deltas)
-
-
- megapixelsPaintedPerSecond = DivideIfPossibleOrZero(
- (totalPixelsPainted / 1000000.0), totalPaintTime)
-
- megapixelsRasterizedPerSecond = DivideIfPossibleOrZero(
- (totalPixelsRasterized / 1000000.0), totalRasterizeTime)
-
- results.Add('mean_frame_time', 'ms', round(mean_frame_time_seconds * 1000, 3))
- results.Add('dropped_percent', '%', round(dropped_percent * 100, 1))
-
- results.Add('total_paint_time', 'seconds', totalPaintTime)
- results.Add('total_rasterize_time', 'seconds', totalRasterizeTime)
- results.Add('total_pixels_painted', '', totalPixelsPainted)
- results.Add('total_pixels_rasterized', '', totalPixelsRasterized)
- results.Add('megapixels_painted_per_second', '', megapixelsPaintedPerSecond)
- results.Add('megapixels_rasterized_per_second', '',
- megapixelsRasterizedPerSecond)
- results.Add('total_paint_and_rasterize_time', 'seconds', totalPaintTime +
- totalRasterizeTime)
-
-class ScrollingBenchmark(multi_page_benchmark.MultiPageBenchmark):
- def __init__(self):
- super(ScrollingBenchmark, self).__init__('scrolling')
-
- def AddCommandLineOptions(self, parser):
- parser.add_option('--no-gpu-benchmarking-extension', action='store_true',
- dest='no_gpu_benchmarking_extension',
- help='Disable the chrome.gpuBenchmarking extension.')
- parser.add_option('--report-all-results', dest='report_all_results',
- action='store_true',
- help='Reports all data collected, not just FPS')
-
- def CustomizeBrowserOptions(self, options):
- if not options.no_gpu_benchmarking_extension:
- options.extra_browser_args.append('--enable-gpu-benchmarking')
-
- def CanRunForPage(self, page):
- return hasattr(page, 'scrolling')
-
- def MeasurePage(self, page, tab, results):
- rendering_stats_deltas = tab.runtime.Evaluate(
- 'window.__renderingStatsDeltas')
-
- if not (rendering_stats_deltas['numFramesSentToScreen'] > 0):
- raise DidNotScrollException()
-
- CalcScrollResults(rendering_stats_deltas, results)
- if self.options.report_all_results:
- for k, v in rendering_stats_deltas.iteritems():
- results.Add(k, '', v)
+ super(ScrollingBenchmark, self).__init__()
diff --git a/tools/perf/perf_tools/smoothness_benchmark.py b/tools/perf/perf_tools/smoothness_benchmark.py
new file mode 100644
index 0000000..fa668db
--- /dev/null
+++ b/tools/perf/perf_tools/smoothness_benchmark.py
@@ -0,0 +1,136 @@
+# 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
+from telemetry import util
+
+class DidNotScrollException(multi_page_benchmark.MeasurementFailure):
+ def __init__(self):
+ super(DidNotScrollException, self).__init__('Page did not scroll')
+
+def GetOrZero(stat, rendering_stats_deltas):
+ if stat in rendering_stats_deltas:
+ return rendering_stats_deltas[stat]
+ return 0
+
+def DivideIfPossibleOrZero(numerator, denominator):
+ if denominator == 0:
+ return 0
+ return numerator / denominator
+
+def CalcScrollResults(rendering_stats_deltas, results):
+ num_frames_sent_to_screen = rendering_stats_deltas['numFramesSentToScreen']
+
+ mean_frame_time_seconds = (
+ rendering_stats_deltas['totalTimeInSeconds'] /
+ float(num_frames_sent_to_screen))
+
+ dropped_percent = (
+ rendering_stats_deltas['droppedFrameCount'] /
+ float(num_frames_sent_to_screen))
+
+ results.Add('mean_frame_time', 'ms', round(mean_frame_time_seconds * 1000, 3))
+ results.Add('dropped_percent', '%', round(dropped_percent * 100, 1),
+ data_type='unimportant')
+
+
+def CalcPaintingResults(rendering_stats_deltas, results):
+ totalPaintTime = GetOrZero('totalPaintTimeInSeconds',
+ rendering_stats_deltas)
+
+ totalRasterizeTime = GetOrZero('totalRasterizeTimeInSeconds',
+ rendering_stats_deltas)
+
+ totalPixelsPainted = GetOrZero('totalPixelsPainted',
+ rendering_stats_deltas)
+
+ totalPixelsRasterized = GetOrZero('totalPixelsRasterized',
+ rendering_stats_deltas)
+
+ megapixelsPaintedPerSecond = DivideIfPossibleOrZero(
+ (totalPixelsPainted / 1000000.0), totalPaintTime)
+
+ megapixelsRasterizedPerSecond = DivideIfPossibleOrZero(
+ (totalPixelsRasterized / 1000000.0), totalRasterizeTime)
+
+ results.Add('total_paint_time', 'seconds', totalPaintTime)
+ results.Add('total_rasterize_time', 'seconds', totalRasterizeTime,
+ data_type='unimportant')
+ results.Add('total_pixels_painted', '', totalPixelsPainted,
+ data_type='unimportant')
+ results.Add('total_pixels_rasterized', '', totalPixelsRasterized,
+ data_type='unimportant')
+ results.Add('megapixels_painted_per_second', '', megapixelsPaintedPerSecond,
+ data_type='unimportant')
+ results.Add('megapixels_rasterized_per_second', '',
+ megapixelsRasterizedPerSecond, data_type='unimportant')
+ results.Add('total_paint_and_rasterize_time', 'seconds', totalPaintTime +
+ totalRasterizeTime, data_type='unimportant')
+
+def CalcTextureUploadResults(rendering_stats_deltas, results):
+ if (('totalCommitCount' not in rendering_stats_deltas)
+ or rendering_stats_deltas['totalCommitCount'] == 0) :
+ averageCommitTimeMs = 0
+ else :
+ averageCommitTimeMs = (
+ 1000 * rendering_stats_deltas['totalCommitTimeInSeconds'] /
+ rendering_stats_deltas['totalCommitCount'])
+
+ results.Add('texture_upload_count', 'count',
+ GetOrZero('textureUploadCount', rendering_stats_deltas))
+ results.Add('average_commit_time', 'ms', averageCommitTimeMs,
+ data_type='unimportant')
+
+def CalcFirstPaintTimeResults(results, tab):
+ if tab.browser.is_content_shell:
+ results.Add('first_paint', 'ms', 'unsupported')
+ return
+
+ tab.runtime.Execute("""
+ window.__rafFired = false;
+ window.webkitRequestAnimationFrame(function() {
+ window.__rafFired = true;
+ });
+ """)
+ util.WaitFor(lambda: tab.runtime.Evaluate('window.__rafFired'), 60)
+
+ first_paint_secs = tab.runtime.Evaluate(
+ 'window.chrome.loadTimes().firstPaintTime - ' +
+ 'window.chrome.loadTimes().requestTime')
+
+ results.Add('first_paint', 'ms', round(first_paint_secs * 1000, 1))
+
+class SmoothnessBenchmark(multi_page_benchmark.MultiPageBenchmark):
+ def __init__(self):
+ super(SmoothnessBenchmark, self).__init__('scrolling')
+
+ def AddCommandLineOptions(self, parser):
+ parser.add_option('--no-gpu-benchmarking-extension', action='store_true',
+ dest='no_gpu_benchmarking_extension',
+ help='Disable the chrome.gpuBenchmarking extension.')
+ parser.add_option('--report-all-results', dest='report_all_results',
+ action='store_true',
+ help='Reports all data collected, not just FPS')
+
+ def CustomizeBrowserOptions(self, options):
+ if not options.no_gpu_benchmarking_extension:
+ options.extra_browser_args.append('--enable-gpu-benchmarking')
+
+ def CanRunForPage(self, page):
+ return hasattr(page, 'scrolling')
+
+ def MeasurePage(self, page, tab, results):
+ rendering_stats_deltas = tab.runtime.Evaluate(
+ 'window.__renderingStatsDeltas')
+
+ if not (rendering_stats_deltas['numFramesSentToScreen'] > 0):
+ raise DidNotScrollException()
+
+ CalcFirstPaintTimeResults(results, tab)
+ CalcScrollResults(rendering_stats_deltas, results)
+ CalcPaintingResults(rendering_stats_deltas, results)
+ CalcTextureUploadResults(rendering_stats_deltas, results)
+
+ if self.options.report_all_results:
+ for k, v in rendering_stats_deltas.iteritems():
+ results.Add(k, '', v)
diff --git a/tools/perf/perf_tools/scrolling_benchmark_unittest.py b/tools/perf/perf_tools/smoothness_benchmark_unittest.py
index 2a02f38..6ee4a03 100644
--- a/tools/perf/perf_tools/scrolling_benchmark_unittest.py
+++ b/tools/perf/perf_tools/smoothness_benchmark_unittest.py
@@ -3,7 +3,7 @@
# found in the LICENSE file.
from telemetry import multi_page_benchmark
from telemetry import multi_page_benchmark_unittest_base
-from perf_tools import scrolling_benchmark
+from perf_tools import smoothness_benchmark
from telemetry import browser_finder
from telemetry import options_for_unittests
@@ -11,13 +11,28 @@ from telemetry import options_for_unittests
import os
import urlparse
-class ScrollingBenchmarkUnitTest(
+class SmoothnessBenchmarkUnitTest(
multi_page_benchmark_unittest_base.MultiPageBenchmarkUnitTestBase):
+ def testFirstPaintTimeMeasurement(self):
+ ps = self.CreatePageSetFromFileInUnittestDataDir('scrollable_page.html')
+
+ benchmark = smoothness_benchmark.SmoothnessBenchmark()
+ 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]
+ if results0['first_paint'] == 'unsupported':
+ # This test can't run on content_shell.
+ return
+ self.assertTrue(results0['first_paint'] > 0)
+
def testScrollingWithGpuBenchmarkingExtension(self):
ps = self.CreatePageSetFromFileInUnittestDataDir('scrollable_page.html')
- benchmark = scrolling_benchmark.ScrollingBenchmark()
+ benchmark = smoothness_benchmark.SmoothnessBenchmark()
all_results = self.RunBenchmark(benchmark, ps)
self.assertEqual(0, len(all_results.page_failures))
@@ -34,7 +49,7 @@ class ScrollingBenchmarkUnitTest(
'numFramesSentToScreen': 10}
res = multi_page_benchmark.BenchmarkResults()
res.WillMeasurePage(True)
- scrolling_benchmark.CalcScrollResults(rendering_stats, res)
+ smoothness_benchmark.CalcScrollResults(rendering_stats, res)
res.DidMeasurePage()
self.assertEquals(50, res.page_results[0]['dropped_percent'])
self.assertAlmostEquals(100, res.page_results[0]['mean_frame_time'], 2)
@@ -54,7 +69,7 @@ class ScrollingBenchmarkUnitTest(
'totalTimeInSeconds': 1.0}
res = multi_page_benchmark.BenchmarkResults()
res.WillMeasurePage(True)
- scrolling_benchmark.CalcScrollResults(rendering_stats, res)
+ smoothness_benchmark.CalcScrollResults(rendering_stats, res)
res.DidMeasurePage()
self.assertEquals(0, res.page_results[0]['dropped_percent'])
self.assertAlmostEquals(1000/60., res.page_results[0]['mean_frame_time'], 2)
@@ -102,7 +117,7 @@ class ScrollingBenchmarkUnitTest(
self.assertTrue(rect_bottom <= viewport_height)
self.assertTrue(rect_right <= viewport_width)
-class ScrollingBenchmarkWithoutGpuBenchmarkingUnitTest(
+class SmoothnessBenchmarkWithoutGpuBenchmarkingUnitTest(
multi_page_benchmark_unittest_base.MultiPageBenchmarkUnitTestBase):
def CustomizeOptionsForTest(self, options):
@@ -111,7 +126,7 @@ class ScrollingBenchmarkWithoutGpuBenchmarkingUnitTest(
def testScrollingWithoutGpuBenchmarkingExtension(self):
ps = self.CreatePageSetFromFileInUnittestDataDir('scrollable_page.html')
- benchmark = scrolling_benchmark.ScrollingBenchmark()
+ benchmark = smoothness_benchmark.SmoothnessBenchmark()
benchmark.use_gpu_benchmarking_extension = False
all_results = self.RunBenchmark(benchmark, ps)
diff --git a/tools/perf/perf_tools/texture_upload_benchmark.py b/tools/perf/perf_tools/texture_upload_benchmark.py
deleted file mode 100644
index 42ad5e0..0000000
--- a/tools/perf/perf_tools/texture_upload_benchmark.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# 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 perf_tools import scrolling_benchmark
-
-class TextureUploadBenchmark(scrolling_benchmark.ScrollingBenchmark):
- def MeasurePage(self, page, tab, results):
- rendering_stats_deltas = self.ScrollPageFully(page, tab)
-
- num_frames_sent_to_screen = rendering_stats_deltas['numFramesSentToScreen']
-
- dropped_percent = (
- rendering_stats_deltas['droppedFrameCount'] /
- float(num_frames_sent_to_screen))
-
- if (('totalCommitCount' not in rendering_stats_deltas)
- or rendering_stats_deltas['totalCommitCount'] == 0) :
- averageCommitTimeMs = 0
- else :
- averageCommitTimeMs = (
- 1000 * rendering_stats_deltas['totalCommitTimeInSeconds'] /
- rendering_stats_deltas['totalCommitCount'])
-
- results.Add('dropped_percent', '%', round(dropped_percent * 100, 1))
- results.Add('texture_upload_count', 'count',
- rendering_stats_deltas['textureUploadCount'])
- results.Add('average_commit_time', 'ms', averageCommitTimeMs)
diff --git a/tools/telemetry/telemetry/multi_page_benchmark_unittest_base.py b/tools/telemetry/telemetry/multi_page_benchmark_unittest_base.py
index 128ff3f..6e49051 100644
--- a/tools/telemetry/telemetry/multi_page_benchmark_unittest_base.py
+++ b/tools/telemetry/telemetry/multi_page_benchmark_unittest_base.py
@@ -22,6 +22,7 @@ class MultiPageBenchmarkUnitTestBase(unittest.TestCase):
def CreatePageSet(self, test_filename):
base_dir = os.path.dirname(__file__)
page = page_module.Page(test_filename, base_dir=base_dir)
+ setattr(page, 'scrolling', {'action': 'scrolling_interaction'})
ps = page_set.PageSet(base_dir=base_dir)
ps.pages.append(page)
return ps