• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2022 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5from __future__ import annotations
6
7from typing import Tuple, Type
8
9from crossbench.probes.android_logcat import AndroidLogcatProbe
10from crossbench.probes.chrome_histograms import ChromeHistogramsProbe
11from crossbench.probes.debugger import DebuggerProbe
12from crossbench.probes.dtrace import DTraceProbe
13from crossbench.probes.dump_html import DumpHtmlProbe
14from crossbench.probes.frequency import FrequencyProbe
15from crossbench.probes.helper import INTERNAL_NAME_PREFIX
16from crossbench.probes.internal import (DurationsProbe, ErrorsProbe,
17                                        InternalProbe, LogProbe,
18                                        ResultsSummaryProbe, SystemDetailsProbe)
19from crossbench.probes.js import JSProbe
20from crossbench.probes.json import JsonResultProbe
21from crossbench.probes.perfetto.perfetto import PerfettoProbe
22from crossbench.probes.perfetto.trace_processor.trace_processor import \
23    TraceProcessorProbe
24from crossbench.probes.perfetto.tracing import TracingProbe
25from crossbench.probes.performance_entries import PerformanceEntriesProbe
26from crossbench.probes.polling import ShellPollingProbe
27from crossbench.probes.power_sampler import PowerSamplerProbe
28from crossbench.probes.powermetrics import PowerMetricsProbe
29from crossbench.probes.probe import Probe
30from crossbench.probes.profiling.browser_profiling import BrowserProfilingProbe
31from crossbench.probes.profiling.system_profiling import ProfilingProbe
32from crossbench.probes.screenshot import ScreenshotProbe
33from crossbench.probes.shell import ShellProbe
34from crossbench.probes.system_stats import SystemStatsProbe
35from crossbench.probes.thermal_monitor import ThermalMonitorProbe
36from crossbench.probes.v8.builtins_pgo import V8BuiltinsPGOProbe
37from crossbench.probes.v8.log import V8LogProbe
38from crossbench.probes.v8.rcs import V8RCSProbe
39from crossbench.probes.v8.turbolizer import V8TurbolizerProbe
40from crossbench.probes.video import VideoProbe
41from crossbench.probes.web_page_replay.recorder import WebPageReplayProbe
42
43ABSTRACT_PROBES: Tuple[Type[Probe], ...] = (Probe, JsonResultProbe)
44
45# Probes that are not user-configurable
46# Order matters, not alpha-sorted:
47# Internal probes depend on each other, for instance the ResultsSummaryProbe
48# reads the values of the other internal probes and thus needs to be the first
49# to be initialized and the last to be teared down to write out a summary
50# result of all the other probes.
51INTERNAL_PROBES: Tuple[Type[InternalProbe], ...] = (
52    ResultsSummaryProbe,
53    DurationsProbe,
54    ErrorsProbe,
55    LogProbe,
56    SystemDetailsProbe,
57    ThermalMonitorProbe,
58)
59# ResultsSummaryProbe should always be processed last, and thus must be the
60# first probe to be added to any browser.
61assert INTERNAL_PROBES[0] == ResultsSummaryProbe
62assert INTERNAL_PROBES[1] == DurationsProbe
63
64# Probes that can be used on arbitrary stories and may be user configurable.
65GENERAL_PURPOSE_PROBES: Tuple[Type[Probe], ...] = (
66    AndroidLogcatProbe,
67    BrowserProfilingProbe,
68    ChromeHistogramsProbe,
69    DTraceProbe,
70    DebuggerProbe,
71    DumpHtmlProbe,
72    FrequencyProbe,
73    JSProbe,
74    PerfettoProbe,
75    PerformanceEntriesProbe,
76    PowerMetricsProbe,
77    PowerSamplerProbe,
78    ProfilingProbe,
79    ScreenshotProbe,
80    ShellPollingProbe,
81    ShellProbe,
82    SystemStatsProbe,
83    TraceProcessorProbe,
84    TracingProbe,
85    V8BuiltinsPGOProbe,
86    V8LogProbe,
87    V8RCSProbe,
88    V8TurbolizerProbe,
89    VideoProbe,
90    WebPageReplayProbe,
91)
92
93for probe_cls in GENERAL_PURPOSE_PROBES:
94  assert probe_cls.IS_GENERAL_PURPOSE, (
95      f"Probe {probe_cls} should be marked for GENERAL_PURPOSE")
96  assert probe_cls.NAME
97  assert not probe_cls.NAME.startswith(INTERNAL_NAME_PREFIX), (
98      f"General purpose {probe_cls}.NAME cannot start with 'cb.'")
99
100for probe_cls in INTERNAL_PROBES:
101  assert not probe_cls.IS_GENERAL_PURPOSE, (
102      f"Internal Probe {probe_cls} should not marked for GENERAL_PURPOSE")
103  assert probe_cls.NAME
104  assert probe_cls.NAME.startswith(INTERNAL_NAME_PREFIX), (
105      f"Internal {probe_cls}.NAME must start with 'cb.'")
106