Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable system_health.mobile* perf tests #21430

Merged
merged 6 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright (c) 2023 The Brave Authors. All rights reserved.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# you can obtain one at http://mozilla.org/MPL/2.0/.

# A override file to add brave perf directories to src/tools/perf/

import os

import override_utils


def _GetSrcDir():
return os.path.abspath(
os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir,
os.pardir, os.pardir))


def _GetBravePerfDir(*dirs):
return os.path.join('brave', 'tools', 'perf', *dirs)


def _GetDiscoverClassesExtras(rel_start_dir, rel_top_level):
if rel_top_level == os.path.join('tools', 'perf', 'page_sets'):
if rel_start_dir == 'system_health':
return 'brave_system_health', _GetBravePerfDir('brave_page_sets')
if rel_top_level == os.path.join('tools', 'perf'):
if rel_start_dir == 'benchmarks':
return 'brave_benchmarks', _GetBravePerfDir()
if rel_start_dir == 'page_sets':
return 'brave_page_sets', _GetBravePerfDir()

return None


@override_utils.override_function(globals())
def DiscoverClasses(original_function, start_dir, top_level_dir, *args,
**kwargs):
original = original_function(start_dir, top_level_dir, *args, **kwargs)
rel_top_level_dir = os.path.relpath(top_level_dir, _GetSrcDir())
rel_start_dir = os.path.relpath(start_dir, top_level_dir)

brave_extras = _GetDiscoverClassesExtras(rel_start_dir, rel_top_level_dir)
if brave_extras is None:
return original
brave_rel_start, brave_rel_top_level = brave_extras

top_level_dir = os.path.join(_GetSrcDir(), brave_rel_top_level)
rel_start_dir = os.path.join(top_level_dir, brave_rel_start)
brave_classes = original_function(rel_start_dir, top_level_dir, *args,
**kwargs)

brave_classes.update(original)
return brave_classes

This file was deleted.

59 changes: 0 additions & 59 deletions chromium_src/tools/perf/benchmarks/loading.py

This file was deleted.

21 changes: 21 additions & 0 deletions chromium_src/tools/perf/benchmarks/system_health.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2023 The Brave Authors. All rights reserved.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at https://mozilla.org/MPL/2.0/.

import override_utils


def _add_brave_metrics(options):
options.ExtendTimelineBasedMetric(['braveNavigationMetric'])
return options


@override_utils.override_method(MobileCommonSystemHealth)
def CreateCoreTimelineBasedMeasurementOptions(self, original_method):
return _add_brave_metrics(original_method(self))


@override_utils.override_method(DesktopCommonSystemHealth)
def CreateCoreTimelineBasedMeasurementOptions(self, original_method):
return _add_brave_metrics(original_method(self))
13 changes: 0 additions & 13 deletions chromium_src/tools/perf/page_sets/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
diff --git a/common/py_utils/py_utils/discover.py b/common/py_utils/py_utils/discover.py
index 7eac0c545a85345f972e1de15f2c2306ba43ff75..8126acc29ec161f39f0bbea66802be53868c0353 100644
--- a/common/py_utils/py_utils/discover.py
+++ b/common/py_utils/py_utils/discover.py
@@ -189,3 +189,4 @@ _COUNTER = [0]
def _GetUniqueModuleName():
_COUNTER[0] += 1
return "module_" + str(_COUNTER[0])
+from import_inline import inline_file_from_src; inline_file_from_src("brave/chromium_src/third_party/catapult/common/py_utils/py_utils/discover.py", globals(), locals())

This file was deleted.

9 changes: 0 additions & 9 deletions patches/tools-perf-benchmarks-loading.py.patch

This file was deleted.

9 changes: 9 additions & 0 deletions patches/tools-perf-benchmarks-system_health.py.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
diff --git a/tools/perf/benchmarks/system_health.py b/tools/perf/benchmarks/system_health.py
index b5d11fb82029d5db007b18d72da03d4bcd357de0..9fd46d179a95c8cd6982da0006fe41b4933802ee 100644
--- a/tools/perf/benchmarks/system_health.py
+++ b/tools/perf/benchmarks/system_health.py
@@ -261,3 +261,4 @@ class WebviewStartupSystemHealthBenchmark(perf_benchmark.PerfBenchmark):
@classmethod
def Name(cls):
return 'system_health.webview_startup'
+from import_inline import inline_file_from_src; inline_file_from_src("brave/chromium_src/tools/perf/benchmarks/system_health.py", globals(), locals())
9 changes: 0 additions & 9 deletions patches/tools-perf-page_sets-__init__.py.patch

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
diff --git a/tools/perf/page_sets/system_health/system_health_stories.py b/tools/perf/page_sets/system_health/system_health_stories.py
index 9bb718effd4dd155a568d8589709a7b915bad847..91f55a3fd2cb5de492086295ae333a7f1edd9726 100644
index 9bb718effd4dd155a568d8589709a7b915bad847..bada3ffe7c40f3049c926a62740d76d09a995c79 100644
--- a/tools/perf/page_sets/system_health/system_health_stories.py
+++ b/tools/perf/page_sets/system_health/system_health_stories.py
@@ -26,7 +26,7 @@ class SystemHealthStorySet(story.StorySet):
take_memory_measurement=False,
tag=None):
super(SystemHealthStorySet, self).__init__(
- archive_data_file=('../data/system_health_%s.json' % platform),
+ archive_data_file=('../../../../brave/tools/perf/page_sets/data/system_health_%s.json' % platform),
+ archive_data_file=('../../../../brave/tools/perf/brave_page_sets/data/system_health_%s.json' % platform),
cloud_storage_bucket=story.PARTNER_BUCKET)

assert platform in platforms.ALL_PLATFORMS
Empty file.
87 changes: 87 additions & 0 deletions tools/perf/brave_benchmarks/brave_loading_desktop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Copyright (c) 2023 The Brave Authors. All rights reserved.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at https://mozilla.org/MPL/2.0/.

# A brave version of loading.desktop benchmark

# Used as part of chromium src/tools/perf/benchmarks/
# Uses the the same code conventions (including pylint).
# pylint: disable=import-error, no-self-use
# pylint: disable=no-name-in-module, too-few-public-methods
# pytype: disable=import-error

import os
import time

from benchmarks import loading_metrics_category

from core import perf_benchmark
from core import platforms

from core.path_util import SysPath, GetChromiumSrcDir

from telemetry import story
from telemetry import benchmark

from telemetry.page import cache_temperature
from telemetry.web_perf import timeline_based_measurement

with SysPath(os.path.join(GetChromiumSrcDir(), 'brave', 'tools', 'perf')):
from brave_page_sets.brave_loading_desktop_pages import (
BraveLoadingDesktopStorySet)


def CreateCoreTBMOptions(metric_list):
tbm_options = timeline_based_measurement.Options()
loading_metrics_category.AugmentOptionsForLoadingMetrics(tbm_options)
cat_filter = tbm_options.config.chrome_trace_config.category_filter
cat_filter.AddDisabledByDefault('disabled-by-default-histogram_samples')
tbm_options.ExtendTimelineBasedMetric(metric_list)
return tbm_options


@benchmark.Info(emails=['matuchin@brave.com', 'iefremov@brave.com'],
component='Blink>Loader',
documentation_url='https://bit.ly/loading-benchmarks')
class LoadingDesktopBrave(perf_benchmark.PerfBenchmark):
""" A benchmark measuring loading performance of desktop sites. """
SUPPORTED_PLATFORM_TAGS = [platforms.DESKTOP]
SUPPORTED_PLATFORMS = [story.expectations.ALL_DESKTOP]

def CreateStorySet(self, _options):
return BraveLoadingDesktopStorySet(
cache_temperatures=[cache_temperature.COLD, cache_temperature.WARM])

def CreateCoreTimelineBasedMeasurementOptions(self):
return CreateCoreTBMOptions(
['braveGeneralUmaMetric', 'braveNavigationMetric'])

def WillRunStory(self, _story):
time.sleep(10)
super().WillRunStory(self, _story)

@classmethod
def Name(cls):
return 'loading.desktop.brave'


@benchmark.Info(emails=['matuchin@brave.com', 'iefremov@brave.com'],
component='Blink>Loader',
documentation_url='https://bit.ly/loading-benchmarks')
class LoadingDesktopBraveStartup(perf_benchmark.PerfBenchmark):
""" A benchmark measuring loading performance of desktop sites. """
SUPPORTED_PLATFORM_TAGS = [platforms.DESKTOP]
SUPPORTED_PLATFORMS = [story.expectations.ALL_DESKTOP]

def CreateStorySet(self, _options):
return BraveLoadingDesktopStorySet(
cache_temperatures=[cache_temperature.COLD, cache_temperature.WARM])

def CreateCoreTimelineBasedMeasurementOptions(self):
return CreateCoreTBMOptions(
['braveGeneralUmaMetric', 'braveStartupUmaMetric'])

@classmethod
def Name(cls):
return 'loading.desktop.brave.startup'
46 changes: 46 additions & 0 deletions tools/perf/brave_benchmarks/brave_utils_benchmarks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright (c) 2023 The Brave Authors. All rights reserved.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at https://mozilla.org/MPL/2.0/.

# A special utility benchmark that doesn't measure anything.
#
# Used as part of chromium src/tools/perf/benchmarks/
# Uses the the same code conventions (including pylint).
# pylint: disable=import-error, no-self-use
# pylint: disable=no-name-in-module, too-few-public-methods
# pytype: disable=import-error

import os

from core import perf_benchmark

from core.path_util import SysPath, GetChromiumSrcDir

with SysPath(os.path.join(GetChromiumSrcDir(), 'brave', 'tools', 'perf')):
from brave_page_sets.brave_perf_utils_pages import BravePerfUtilsStorySet


class BraveUtilsBenchmark(perf_benchmark.PerfBenchmark):
"""A special benchmark for utility purposes.

Doesn't measure anything.
"""

def CreateStorySet(self, _options):
return BravePerfUtilsStorySet()

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


class BraveUtilsOnlineBenchmark(BraveUtilsBenchmark):
"""A version of BraveUtilsBenchmark with an internet connection."""
options = {
'use_live_sites': True,
}

@classmethod
def Name(cls):
return 'brave_utils.online'
4 changes: 0 additions & 4 deletions tools/perf/brave_page_sets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
# Copyright (c) 2022 The Brave Authors. All rights reserved.
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# you can obtain one at http://mozilla.org/MPL/2.0/.
Loading