File: speedometer3.py

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (257 lines) | stat: -rw-r--r-- 8,388 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Speedometer 3 Web Interaction Benchmark Pages
"""

import os
import re

from benchmarks import press

from core import path_util

from telemetry import benchmark
from telemetry import story
from telemetry.timeline import chrome_trace_category_filter
from telemetry.web_perf import timeline_based_measurement

from page_sets import speedometer3_pages

_SPEEDOMETER_DIR = os.path.join(path_util.GetChromiumSrcDir(), 'third_party',
                                'speedometer')


class _Speedometer3(press._PressBenchmark):  # pylint: disable=protected-access
  """Abstract base Speedometer 3.x Benchmark class.

  Runs all the speedometer 3 suites by default. Add --suite=<regex> to filter
  out suites, and only run suites whose names are matched by the regular
  expression provided.
  """

  enable_smoke_test_mode = False
  enable_systrace = False
  extra_chrome_categories = False
  enable_rcs = False
  enable_details = False
  iteration_count = None
  take_memory_measurement = False

  @classmethod
  def GetStoryClass(cls):
    raise NotImplementedError()

  def CreateStorySet(self, options):
    should_filter_suites = bool(options.suite)
    story_cls = self.GetStoryClass()
    filtered_suite_names = story_cls.GetSuites(options.suite)

    story_set = story.StorySet(base_dir=self._SOURCE_DIR)

    # For a smoke test one iteration is sufficient
    if self.enable_smoke_test_mode and not self.iteration_count:
      iteration_count = 1
    else:
      iteration_count = self.iteration_count

    story_set.AddStory(
        story_cls(story_set, should_filter_suites, filtered_suite_names,
                  iteration_count, self.enable_details,
                  self.take_memory_measurement))
    return story_set

  def CreateCoreTimelineBasedMeasurementOptions(self):
    if not self.enable_systrace:
      return timeline_based_measurement.Options()

    cat_filter = chrome_trace_category_filter.ChromeTraceCategoryFilter()

    if self.take_memory_measurement:
      cat_filter.AddDisabledByDefault('disabled-by-default-memory-infra')

    # Used for marking ranges in cache_temperature.MarkTelemetryInternal.
    cat_filter.AddIncludedCategory('blink.console')

    # Used to capture TaskQueueManager events.
    cat_filter.AddIncludedCategory('toplevel')

    if self.extra_chrome_categories:
      cat_filter.AddFilterString(self.extra_chrome_categories)

    if self.enable_rcs:
      # V8 needed categories
      cat_filter.AddIncludedCategory('v8')
      cat_filter.AddDisabledByDefault('disabled-by-default-v8.runtime_stats')

      tbm_options = timeline_based_measurement.Options(
          overhead_level=cat_filter)
      tbm_options.SetTimelineBasedMetrics(['runtimeStatsTotalMetric'])
      return tbm_options

    tbm_options = timeline_based_measurement.Options(overhead_level=cat_filter)
    tbm_options.SetTimelineBasedMetrics(['tracingMetric'])
    return tbm_options

  def SetExtraBrowserOptions(self, options):
    if self.enable_rcs:
      options.AppendExtraBrowserArgs(
          '--enable-blink-features=BlinkRuntimeCallStats')

  @classmethod
  def AddBenchmarkCommandLineArgs(cls, parser):
    parser.add_argument('--suite',
                        help='Only runs suites that match regex provided')
    parser.add_argument('--enable-rcs',
                        '--rcs',
                        action='store_true',
                        help='Enables runtime call stats')
    parser.add_argument('--enable-details',
                        '--details',
                        action='store_true',
                        help=('Enables detailed benchmark metrics '
                              '(per line-item, iteration,...)'))
    parser.add_argument('--iteration-count',
                        '--iterations',
                        type=int,
                        help='Override the default number of iterations')

  @classmethod
  def ProcessCommandLineArgs(cls, parser, args):
    if args.suite:
      try:
        if not cls.GetStoryClass().GetSuites(args.suite):
          raise parser.error('--suite: No matches.')
      except re.error:
        raise parser.error('--suite: Invalid regex.')
    if args.enable_systrace or args.enable_rcs:
      cls.enable_systrace = True
    if args.extra_chrome_categories:
      cls.extra_chrome_categories = args.extra_chrome_categories
    if args.enable_rcs:
      cls.enable_rcs = True
    if args.enable_details:
      cls.enable_details = True
    if args.iteration_count:
      cls.iteration_count = args.iteration_count


@benchmark.Info(emails=['cbruni@chromium.org', 'vahl@chromium.org'],
                component='Blink>JavaScript',
                documentation_url='https://github.com/WebKit/Speedometer')
class Speedometer30(_Speedometer3):
  """Speedometer 3.0 benchmark.
  Explicitly named version."""

  SCHEDULED = False
  _SOURCE_DIR = os.path.join(_SPEEDOMETER_DIR, 'v3.0')

  @classmethod
  def GetStoryClass(cls):
    return speedometer3_pages.Speedometer30Story

  @classmethod
  def Name(cls):
    return 'speedometer3.0'


@benchmark.Info(emails=['cbruni@chromium.org', 'vahl@chromium.org'],
                component='Blink>JavaScript',
                documentation_url='https://github.com/WebKit/Speedometer')
class Speedometer31(_Speedometer3):
  """Speedometer 3.1 benchmark.
  Explicitly named version."""

  SCHEDULED = False
  _SOURCE_DIR = os.path.join(_SPEEDOMETER_DIR, 'v3.1')

  @classmethod
  def GetStoryClass(cls):
    return speedometer3_pages.Speedometer31Story

  @classmethod
  def Name(cls):
    return 'speedometer3.1'


@benchmark.Info(emails=['cbruni@chromium.org', 'vahl@chromium.org'],
                component='Blink>JavaScript',
                documentation_url='https://github.com/WebKit/Speedometer')
class Speedometer3(Speedometer31):
  """The latest version of the Speedometer 3.x benchmark."""
  SCHEDULED = True

  @classmethod
  def GetStoryClass(cls):
    return speedometer3_pages.Speedometer3Story

  @classmethod
  def Name(cls):
    return 'speedometer3'


@benchmark.Info(emails=['cbruni@chromium.org', 'vahl@chromium.org'],
                component='Blink>JavaScript',
                documentation_url='https://github.com/WebKit/Speedometer')
class Speedometer3Future(Speedometer3):
  """The latest Speedometer 3.x benchmark with the V8 flag --future.

  Shows the performance of upcoming V8 VM features.
  """
  @classmethod
  def Name(cls):
    return 'speedometer3-future'

  def SetExtraBrowserOptions(self, options):
    options.AppendExtraBrowserArgs('--enable-features=V8VmFuture')


@benchmark.Info(emails=['omerkatz@chromium.org'],
                component='Blink>JavaScript>GarbageCollection',
                documentation_url='https://github.com/WebKit/Speedometer')
class Speedometer3MinorMS(Speedometer3):
  """The latest Speedometer 3.x benchmark without the MinorMS flag.

  Shows the performance of Scavenger young generation GC in V8.
  """
  @classmethod
  def Name(cls):
    return 'speedometer3-minorms'

  def SetExtraBrowserOptions(self, options):
    options.AppendExtraBrowserArgs('--js-flags=--minor-ms')


@benchmark.Info(emails=['rasikan@google.com', 'wnwen@google.com'],
                component='Blink>JavaScript',
                documentation_url='https://github.com/WebKit/Speedometer')
class Speedometer3Predictable(Speedometer3):
  """The latest Speedometer 3.x benchmark with V8's `predictable` mode.

  This should (hopefully) help reduce variance in the score.
  """

  @classmethod
  def Name(cls):
    return 'speedometer3-predictable'

  def SetExtraBrowserOptions(self, options):
    options.AppendExtraBrowserArgs('--js-flags=--predictable')


@benchmark.Info(emails=['cbruni@chromium.org', 'vahl@chromium.org'],
                component='Blink>JavaScript',
                documentation_url='https://github.com/WebKit/Speedometer')
class Speedometer3NoFieldTrials(Speedometer3):
  """The latest Speedometer 3.x benchmark without field-trials.
  """

  SCHEDULED = False

  @classmethod
  def Name(cls):
    return 'speedometer3-no-field-trials'

  def SetExtraBrowserOptions(self, options):
    options.AppendExtraBrowserArgs('--disable-field-trial-config')
    options.RemoveExtraBrowserArg('--enable-field-trial-config')