1# Copyright 2017 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""Apple's Speedometer 2 performance benchmark.
6"""
7
8import os
9import re
10
11from benchmarks import press
12
13from core import path_util
14
15from telemetry import benchmark
16from telemetry import story
17
18from page_sets import speedometer2_pages
19
20_SPEEDOMETER_DIR = os.path.join(path_util.GetChromiumSrcDir(),
21    'third_party', 'blink', 'perf_tests', 'speedometer')
22
23@benchmark.Info(emails=['hablich@chromium.org'],
24                component='Blink')
25class Speedometer2(press._PressBenchmark): # pylint: disable=protected-access
26  """Speedometer2 Benchmark.
27
28  Runs all the speedometer 2 suites by default. Add --suite=<regex> to filter
29  out suites, and only run suites whose names are matched by the regular
30  expression provided.
31  """
32
33  enable_smoke_test_mode = False
34
35  @classmethod
36  def Name(cls):
37    return 'speedometer2'
38
39  def CreateStorySet(self, options):
40    should_filter_suites = bool(options.suite)
41    filtered_suite_names = map(
42        speedometer2_pages.Speedometer2Story.GetFullSuiteName,
43            speedometer2_pages.Speedometer2Story.GetSuites(options.suite))
44
45    ps = story.StorySet(base_dir=_SPEEDOMETER_DIR)
46    ps.AddStory(speedometer2_pages.Speedometer2Story(ps, should_filter_suites,
47        filtered_suite_names, self.enable_smoke_test_mode))
48    return ps
49
50  @classmethod
51  def AddBenchmarkCommandLineArgs(cls, parser):
52    parser.add_option('--suite', type="string",
53                      help="Only runs suites that match regex provided")
54
55  @classmethod
56  def ProcessCommandLineArgs(cls, parser, args):
57    if args.suite:
58      try:
59        if not speedometer2_pages.Speedometer2Story.GetSuites(args.suite):
60          raise parser.error('--suite: No matches.')
61      except re.error:
62        raise parser.error('--suite: Invalid regex.')
63
64
65@benchmark.Info(emails=['hablich@chromium.org'],
66                component='Blink')
67class V8Speedometer2Future(Speedometer2):
68  """Speedometer2 benchmark with the V8 flag --future.
69
70  Shows the performance of upcoming V8 VM features.
71  """
72
73  @classmethod
74  def Name(cls):
75    return 'speedometer2-future'
76
77  def SetExtraBrowserOptions(self, options):
78    options.AppendExtraBrowserArgs('--enable-features=V8VmFuture')
79