Commit e273fc52 authored by tonyg@chromium.org's avatar tonyg@chromium.org

[Telemetry] Make session restore benchmark not require arguments.

Previously, this benchmark required a separate profile generation step as wel
as arguments. This isn't a Telemetric way to write a benchmark. Now, if a
profile isn't given, it generates the correct profile for the benchmark.

BUG=

Review URL: https://codereview.chromium.org/317733002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275458 0039d316-1c4b-4281-b951-d872f2087c98
parent 50b8fa5d
......@@ -2,12 +2,35 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
import tempfile
from measurements import session_restore
from measurements import session_restore_with_url
from profile_creators import small_profile_creator
from telemetry import test
from telemetry.page import profile_generator
class _SessionRestoreTest(test.Test):
@classmethod
def ProcessCommandLineArgs(cls, parser, args):
super(_SessionRestoreTest, cls).ProcessCommandLineArgs(parser, args)
profile_type = 'small_profile'
if not args.browser_options.profile_dir:
profile_dir = os.path.join(tempfile.gettempdir(), profile_type)
if not os.path.exists(profile_dir):
new_args = args.Copy()
new_args.pageset_repeat = 1
new_args.output_dir = profile_dir
profile_generator.GenerateProfiles(
small_profile_creator.SmallProfileCreator, profile_type, new_args)
args.browser_options.profile_dir = os.path.join(profile_dir, profile_type)
@test.Disabled('android') # crbug.com/325479
class SessionRestoreColdTypical25(test.Test):
class SessionRestoreColdTypical25(_SessionRestoreTest):
tag = 'cold'
test = session_restore.SessionRestore
page_set = 'page_sets/typical_25.py'
......@@ -15,9 +38,27 @@ class SessionRestoreColdTypical25(test.Test):
'pageset_repeat': 5}
class SessionRestoreWarmTypical25(test.Test):
class SessionRestoreWarmTypical25(_SessionRestoreTest):
tag = 'warm'
test = session_restore.SessionRestore
page_set = 'page_sets/typical_25.py'
options = {'warm': True,
'pageset_repeat': 20}
class SessionRestoreWithUrlCold(_SessionRestoreTest):
"""Measure Chrome cold session restore with startup URLs."""
tag = 'cold'
test = session_restore_with_url.SessionRestoreWithUrl
page_set = 'page_sets/startup_pages.py'
options = {'cold': True,
'pageset_repeat': 5}
class SessionRestoreWithUrlWarm(_SessionRestoreTest):
"""Measure Chrome warm session restore with startup URLs."""
tag = 'warm'
test = session_restore_with_url.SessionRestoreWithUrl
page_set = 'page_sets/startup_pages.py'
options = {'warm': True,
'pageset_repeat': 10}
# Copyright 2014 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 test
from measurements import session_restore_with_url
class SessionRestoreWithUrlCold(test.Test):
"""Measure Chrome cold session restore with startup URLs."""
tag = 'cold'
test = session_restore_with_url.SessionRestoreWithUrl
page_set = 'page_sets/startup_pages.py'
options = {'cold': True,
'pageset_repeat': 5}
class SessionRestoreWithUrlWarm(test.Test):
"""Measure Chrome warm session restore with startup URLs."""
tag = 'warm'
test = session_restore_with_url.SessionRestoreWithUrl
page_set = 'page_sets/startup_pages.py'
options = {'warm': True,
'pageset_repeat': 10}
......@@ -308,12 +308,17 @@ class BrowserOptions(object):
self.dont_override_profile = True
if self.profile_dir and self.profile_type != 'clean':
raise Exception("It's illegal to specify both --profile-type and"
" --profile-dir.")
logging.critical(
"It's illegal to specify both --profile-type and --profile-dir.\n"
"For more information see: http://goo.gl/ngdGD5")
sys.exit(1)
if self.profile_dir and not os.path.isdir(self.profile_dir):
raise Exception("Directory specified by --profile-dir (%s) doesn't"
" exist or isn't a directory." % (self.profile_dir))
logging.critical(
"Directory specified by --profile-dir (%s) doesn't exist "
"or isn't a directory.\n"
"For more information see: http://goo.gl/ngdGD5" % self.profile_dir)
sys.exit(1)
if not self.profile_dir:
self.profile_dir = profile_types.GetProfileDir(self.profile_type)
......
......@@ -155,8 +155,8 @@ class Run(command_line.OptparseCommand):
assert issubclass(test_class, test.Test), 'Trying to run a non-Test?!'
test_class.ProcessCommandLineArgs(parser, args)
test.ProcessCommandLineArgs(parser, args)
test_class.ProcessCommandLineArgs(parser, args)
cls._test = test_class
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment