summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorrmistry <rmistry@google.com>2015-10-15 09:53:48 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-15 16:54:26 +0000
commit6b539126337ade3771ec901867a1f2af58662f04 (patch)
treea83d0cfbb1167ae6c545c0e8ffc4930fe5752e1b /tools
parente3937f296b9f90f4ddfdaaca7136212ae40b858b (diff)
downloadchromium_src-6b539126337ade3771ec901867a1f2af58662f04.zip
chromium_src-6b539126337ade3771ec901867a1f2af58662f04.tar.gz
chromium_src-6b539126337ade3771ec901867a1f2af58662f04.tar.bz2
Move CT pages / page sets / benchmarks into Telemetry repo.
Context: In https://codereview.chromium.org/730033005/#msg15 I was convinced to create a ct_run_benchmark and my own copy of benchmarks in the CT repository ( https://skia.googlesource.com/buildbot/+/master/ct/py/ct_run_benchmark and https://skia.googlesource.com/buildbot/+/master/ct/py/benchmarks/ ). In retrospect this was not a good idea, because: When there are upstream changes only benchmarks in telemetry repo will be updated, CT benchmarks will break. Moving this into telemetry repo makes things much more maintainable. BUG=skia:4435 CQ_EXTRA_TRYBOTS=tryserver.chromium.perf:mac_10_10_perf_bisect Review URL: https://codereview.chromium.org/1393023002 Cr-Commit-Position: refs/heads/master@{#354285}
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/benchmarks/ct_benchmarks_unittest.py115
-rw-r--r--tools/perf/benchmarks/rasterize_and_record_micro.py25
-rw-r--r--tools/perf/benchmarks/repaint.py24
-rw-r--r--tools/perf/benchmarks/skpicture_printer.py31
-rwxr-xr-xtools/perf/ct_benchmarks_util.py25
-rw-r--r--tools/perf/page_sets/ct_page_set.py45
6 files changed, 265 insertions, 0 deletions
diff --git a/tools/perf/benchmarks/ct_benchmarks_unittest.py b/tools/perf/benchmarks/ct_benchmarks_unittest.py
new file mode 100644
index 0000000..40c55d2
--- /dev/null
+++ b/tools/perf/benchmarks/ct_benchmarks_unittest.py
@@ -0,0 +1,115 @@
+# Copyright 2015 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 optparse import OptionParser
+import unittest
+
+from telemetry.page import shared_page_state
+
+from benchmarks import rasterize_and_record_micro
+from benchmarks import repaint
+from benchmarks import skpicture_printer
+
+
+class MockErrorParser(object):
+ def __init__(self):
+ self.err_msg = None
+
+ def error(self, err_msg):
+ self.err_msg = err_msg
+
+
+class CTBenchmarks(unittest.TestCase):
+
+ def setUp(self):
+ self.ct_benchmarks = [
+ rasterize_and_record_micro.RasterizeAndRecordMicroCT(),
+ repaint.RepaintCT(),
+ skpicture_printer.SkpicturePrinterCT(),
+ ]
+ self.shared_page_state_class = shared_page_state.SharedMobilePageState
+ self.archive_data_file = '/b/test'
+ self.urls_list = 'http://test1.com,http://test2.com,http://test3.net'
+ self.mock_parser = MockErrorParser()
+
+ def testCTBenchmarks(self):
+ for benchmark in self.ct_benchmarks:
+ parser = OptionParser()
+ parser.user_agent = 'mobile'
+ parser.archive_data_file = self.archive_data_file
+ parser.urls_list = self.urls_list
+
+ benchmark.AddBenchmarkCommandLineArgs(parser)
+ benchmark.ProcessCommandLineArgs(None, parser)
+ ct_page_set = benchmark.CreateStorySet(parser)
+
+ self.assertEquals(
+ len(self.urls_list.split(',')), len(ct_page_set.stories))
+ self.assertEquals(
+ self.archive_data_file, ct_page_set.archive_data_file)
+ for i in range(len(self.urls_list.split(','))):
+ url = self.urls_list.split(',')[i]
+ story = ct_page_set.stories[i]
+ self.assertEquals(url, story.url)
+ self.assertEquals(
+ self.shared_page_state_class, story.shared_state_class)
+ self.assertEquals(self.archive_data_file, story.archive_data_file)
+
+ def testCTBenchmarks_wrongAgent(self):
+ for benchmark in self.ct_benchmarks:
+ parser = OptionParser()
+ parser.user_agent = 'mobileeeeee'
+ parser.archive_data_file = self.archive_data_file
+ parser.urls_list = self.urls_list
+
+ benchmark.AddBenchmarkCommandLineArgs(parser)
+ benchmark.ProcessCommandLineArgs(None, parser)
+ try:
+ benchmark.CreateStorySet(parser)
+ self.fail('Expected ValueError')
+ except ValueError, e:
+ self.assertEquals('user_agent mobileeeeee is unrecognized', e.message)
+
+ def testCTBenchmarks_missingDataFile(self):
+ for benchmark in self.ct_benchmarks:
+ parser = OptionParser()
+ parser.user_agent = 'mobile'
+ parser.urls_list = self.urls_list
+ benchmark.AddBenchmarkCommandLineArgs(parser)
+
+ # Should fail due to missing archive_data_file.
+ try:
+ benchmark.ProcessCommandLineArgs(None, parser)
+ self.fail('Expected AttributeError')
+ except AttributeError, e:
+ self.assertEquals(
+ 'OptionParser instance has no attribute \'archive_data_file\'',
+ e.message)
+
+ # Now add an empty archive_data_file.
+ parser.archive_data_file = ''
+ benchmark.ProcessCommandLineArgs(self.mock_parser, parser)
+ self.assertEquals(
+ 'Please specify --archive_data_file.', self.mock_parser.err_msg)
+
+ def testCTBenchmarks_missingUrlsList(self):
+ for benchmark in self.ct_benchmarks:
+ parser = OptionParser()
+ parser.user_agent = 'mobile'
+ parser.archive_data_file = self.archive_data_file
+ benchmark.AddBenchmarkCommandLineArgs(parser)
+
+ # Should fail due to missing urls_list.
+ try:
+ benchmark.ProcessCommandLineArgs(None, parser)
+ self.fail('Expected AttributeError')
+ except AttributeError, e:
+ self.assertEquals(
+ 'OptionParser instance has no attribute \'urls_list\'',
+ e.message)
+
+ # Now add an empty urls_list.
+ parser.urls_list = ''
+ benchmark.ProcessCommandLineArgs(self.mock_parser, parser)
+ self.assertEquals('Please specify --urls_list.', self.mock_parser.err_msg)
diff --git a/tools/perf/benchmarks/rasterize_and_record_micro.py b/tools/perf/benchmarks/rasterize_and_record_micro.py
index 9a5abab..75e9541 100644
--- a/tools/perf/benchmarks/rasterize_and_record_micro.py
+++ b/tools/perf/benchmarks/rasterize_and_record_micro.py
@@ -4,6 +4,7 @@
from core import perf_benchmark
+import ct_benchmarks_util
from measurements import rasterize_and_record_micro
import page_sets
from telemetry import benchmark
@@ -95,3 +96,27 @@ class RasterizeAndRecordMicroPolymer(_RasterizeAndRecordMicro):
def CreateStorySet(self, options):
return page_sets.PolymerPageSet(run_no_page_interactions=True)
+
+
+# Disabled because we do not plan on running CT benchmarks on the perf
+# waterfall any time soon.
+@benchmark.Disabled
+class RasterizeAndRecordMicroCT(_RasterizeAndRecordMicro):
+ """Measures rasterize and record performance for Cluster Telemetry."""
+
+ @classmethod
+ def Name(cls):
+ return 'rasterize_and_record_micro_ct'
+
+ @classmethod
+ def AddBenchmarkCommandLineArgs(cls, parser):
+ _RasterizeAndRecordMicro.AddBenchmarkCommandLineArgs(parser)
+ ct_benchmarks_util.AddBenchmarkCommandLineArgs(parser)
+
+ @classmethod
+ def ProcessCommandLineArgs(cls, parser, args):
+ ct_benchmarks_util.ValidateCommandLineArgs(parser, args)
+
+ def CreateStorySet(self, options):
+ return page_sets.CTPageSet(
+ options.urls_list, options.user_agent, options.archive_data_file)
diff --git a/tools/perf/benchmarks/repaint.py b/tools/perf/benchmarks/repaint.py
index 2293c04..569d381 100644
--- a/tools/perf/benchmarks/repaint.py
+++ b/tools/perf/benchmarks/repaint.py
@@ -5,6 +5,7 @@
from core import perf_benchmark
from benchmarks import silk_flags
+import ct_benchmarks_util
from measurements import smoothness
import page_sets
from telemetry import benchmark
@@ -64,3 +65,26 @@ class RepaintGpuRasterizationKeyMobileSites(_Repaint):
def Name(cls):
return 'repaint.gpu_rasterization.key_mobile_sites_repaint'
+
+# Disabled because we do not plan on running CT benchmarks on the perf
+# waterfall any time soon.
+@benchmark.Disabled
+class RepaintCT(_Repaint):
+ """Measures repaint performance for Cluster Telemetry."""
+
+ @classmethod
+ def Name(cls):
+ return 'repaint_ct'
+
+ @classmethod
+ def AddBenchmarkCommandLineArgs(cls, parser):
+ _Repaint.AddBenchmarkCommandLineArgs(parser)
+ ct_benchmarks_util.AddBenchmarkCommandLineArgs(parser)
+
+ @classmethod
+ def ProcessCommandLineArgs(cls, parser, args):
+ ct_benchmarks_util.ValidateCommandLineArgs(parser, args)
+
+ def CreateStorySet(self, options):
+ return page_sets.CTPageSet(
+ options.urls_list, options.user_agent, options.archive_data_file)
diff --git a/tools/perf/benchmarks/skpicture_printer.py b/tools/perf/benchmarks/skpicture_printer.py
index 0247320..3ba8834 100644
--- a/tools/perf/benchmarks/skpicture_printer.py
+++ b/tools/perf/benchmarks/skpicture_printer.py
@@ -4,6 +4,8 @@
from core import perf_benchmark
+import ct_benchmarks_util
+import page_sets
from telemetry import benchmark
from telemetry.core import discover
from telemetry import story
@@ -48,3 +50,32 @@ class SkpicturePrinter(perf_benchmark.PerfBenchmark):
story_set_class = _MatchPageSetName(options.page_set_name,
options.page_set_base_dir)
return story_set_class()
+
+
+# Disabled because we do not plan on running CT benchmarks on the perf
+# waterfall any time soon.
+@benchmark.Disabled
+class SkpicturePrinterCT(perf_benchmark.PerfBenchmark):
+ """Captures SKPs for Cluster Telemetry."""
+
+ @classmethod
+ def Name(cls):
+ return 'skpicture_printer_ct'
+
+ @classmethod
+ def AddBenchmarkCommandLineArgs(cls, parser):
+ ct_benchmarks_util.AddBenchmarkCommandLineArgs(parser)
+ parser.add_option('-s', '--skp-outdir',
+ default=None,
+ help='Output directory for the SKP files')
+
+ @classmethod
+ def ProcessCommandLineArgs(cls, parser, args):
+ ct_benchmarks_util.ValidateCommandLineArgs(parser, args)
+
+ def CreatePageTest(self, options):
+ return skpicture_printer.SkpicturePrinter(options.skp_outdir)
+
+ def CreateStorySet(self, options):
+ return page_sets.CTPageSet(
+ options.urls_list, options.user_agent, options.archive_data_file)
diff --git a/tools/perf/ct_benchmarks_util.py b/tools/perf/ct_benchmarks_util.py
new file mode 100755
index 0000000..d82a8bf
--- /dev/null
+++ b/tools/perf/ct_benchmarks_util.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+# Copyright (c) 2015 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.
+
+
+def AddBenchmarkCommandLineArgs(parser):
+ parser.add_option('--user-agent', action='store', type='string',
+ default=None, help='Options are mobile and desktop.')
+ parser.add_option('--archive-data-file', action='store', type='string',
+ default=None,
+ help='The location of the WPR JSON archive file.')
+ parser.add_option('--urls-list', action='store', type='string',
+ default=None,
+ help='This is a comma separated list of urls. '
+ 'Eg: http://www.google.com,http://www.gmail.com')
+
+
+def ValidateCommandLineArgs(parser, args):
+ if not args.user_agent:
+ parser.error('Please specify --user_agent.')
+ if not args.archive_data_file:
+ parser.error('Please specify --archive_data_file.')
+ if not args.urls_list:
+ parser.error('Please specify --urls_list.')
diff --git a/tools/perf/page_sets/ct_page_set.py b/tools/perf/page_sets/ct_page_set.py
new file mode 100644
index 0000000..97debad
--- /dev/null
+++ b/tools/perf/page_sets/ct_page_set.py
@@ -0,0 +1,45 @@
+# Copyright 2015 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 page_sets import repaint_helpers
+
+from telemetry.page import page as page_module
+from telemetry.page import shared_page_state
+from telemetry import story
+
+
+class CTPage(page_module.Page):
+
+ def __init__(self, url, page_set, shared_page_state_class, archive_data_file):
+ super(CTPage, self).__init__(
+ url=url,
+ page_set=page_set,
+ shared_page_state_class=shared_page_state_class)
+ self.archive_data_file = archive_data_file
+
+ def RunNavigateSteps(self, action_runner):
+ action_runner.Navigate(self.url)
+ action_runner.Wait(2)
+
+ def RunPageInteractions(self, action_runner):
+ repaint_helpers.Repaint(action_runner)
+
+
+class CTPageSet(story.StorySet):
+ """Page set used by CT Benchmarks."""
+
+ def __init__(self, urls_list, user_agent, archive_data_file):
+ if user_agent == 'mobile':
+ shared_page_state_class = shared_page_state.SharedMobilePageState
+ elif user_agent == 'desktop':
+ shared_page_state_class = shared_page_state.SharedDesktopPageState
+ else:
+ raise ValueError('user_agent %s is unrecognized' % user_agent)
+
+ super(CTPageSet, self).__init__(archive_data_file=archive_data_file)
+
+ for url in urls_list.split(','):
+ self.AddStory(
+ CTPage(url, self, shared_page_state_class, archive_data_file))