diff --git a/ci/fireci/fireciplugins/macrobenchmark.py b/ci/fireci/fireciplugins/macrobenchmark.py index 0494c2f65b0..a0fc2f81a39 100644 --- a/ci/fireci/fireciplugins/macrobenchmark.py +++ b/ci/fireci/fireciplugins/macrobenchmark.py @@ -21,6 +21,7 @@ import re import shutil import sys +import tempfile import uuid import click @@ -31,42 +32,55 @@ from fireci import ci_command from fireci import ci_utils -from fireci.dir_utils import chdir from fireci import uploader +from fireci.dir_utils import chdir _logger = logging.getLogger('fireci.macrobenchmark') +@click.option( + '--build-only/--no-build-only', + default=False, + help='Whether to only build tracing test apps or to also run them on FTL afterwards' +) @ci_command() -def macrobenchmark(): +def macrobenchmark(build_only): """Measures app startup times for Firebase SDKs.""" - asyncio.run(_launch_macrobenchmark_test()) + asyncio.run(_launch_macrobenchmark_test(build_only)) -async def _launch_macrobenchmark_test(): +async def _launch_macrobenchmark_test(build_only): _logger.info('Starting macrobenchmark test...') - artifact_versions, config, _, _ = await asyncio.gather( - _parse_artifact_versions(), - _parse_config_yaml(), - _create_gradle_wrapper(), - _copy_google_services(), - ) - + artifact_versions = await _assemble_all_artifacts() _logger.info(f'Artifact versions: {artifact_versions}') - with chdir('health-metrics/macrobenchmark'): - runners = [MacrobenchmarkTest(k, v, artifact_versions) for k, v in config.items()] - results = await asyncio.gather(*[x.run() for x in runners], return_exceptions=True) + test_dir = await _prepare_test_directory() + _logger.info(f'Directory for test apps: {test_dir}') + + config = await _process_config_yaml() + _logger.info(f'Processed yaml configurations: {config}') + + tests = [MacrobenchmarkTest(app, artifact_versions, os.getcwd(), test_dir) for app in config['test-apps']] - await _post_processing(results) + _logger.info(f'Building {len(tests)} macrobenchmark test apps...') + # TODO(yifany): investigate why it is much slower with asyncio.gather + # - on corp workstations (9 min) than M1 macbook pro (3 min) + # - with gradle 7.5.1 (9 min) than gradle 6.9.2 (5 min) + # await asyncio.gather(*[x.build() for x in tests]) + for test in tests: + await test.build() + + if not build_only: + _logger.info(f'Submitting {len(tests)} tests to Firebase Test Lab...') + results = await asyncio.gather(*[x.test() for x in tests], return_exceptions=True) + await _post_processing(results) _logger.info('Macrobenchmark test finished.') -async def _parse_artifact_versions(): - proc = await asyncio.subprocess.create_subprocess_exec('./gradlew', 'assembleAllForSmokeTests') - await proc.wait() +async def _assemble_all_artifacts(): + await (await asyncio.create_subprocess_exec('./gradlew', 'assembleAllForSmokeTests')).wait() with open('build/m2repository/changed-artifacts.json') as json_file: artifacts = json.load(json_file) @@ -78,35 +92,36 @@ def _artifact_key_version(artifact): return f'{group_id}:{artifact_id}', version -async def _parse_config_yaml(): - with open('health-metrics/macrobenchmark/config.yaml') as yaml_file: - return yaml.safe_load(yaml_file) +async def _process_config_yaml(): + with open('health-metrics/benchmark/config.yaml') as yaml_file: + config = yaml.safe_load(yaml_file) + for app in config['test-apps']: + app['plugins'] = app.get('plugins', []) + app['traces'] = app.get('traces', []) + app['plugins'].extend(config['common-plugins']) + app['traces'].extend(config['common-traces']) + return config -async def _create_gradle_wrapper(): - with open('health-metrics/macrobenchmark/settings.gradle', 'w'): - pass +async def _prepare_test_directory(): + test_dir = tempfile.mkdtemp(prefix='benchmark-test-') - proc = await asyncio.subprocess.create_subprocess_exec( - './gradlew', - 'wrapper', - '--gradle-version', - '6.9', - '--project-dir', - 'health-metrics/macrobenchmark' - ) - await proc.wait() + # Required for creating gradle wrapper, as the dir is not defined in the root settings.gradle + open(os.path.join(test_dir, 'settings.gradle'), 'w').close() + command = ['./gradlew', 'wrapper', '--gradle-version', '7.5.1', '--project-dir', test_dir] + await (await asyncio.create_subprocess_exec(*command)).wait() -async def _copy_google_services(): - if 'FIREBASE_CI' in os.environ: - src = os.environ['FIREBASE_GOOGLE_SERVICES_PATH'] - dst = 'health-metrics/macrobenchmark/template/app/google-services.json' - _logger.info(f'Running on CI. Copying "{src}" to "{dst}"...') - shutil.copyfile(src, dst) + return test_dir async def _post_processing(results): + _logger.info(f'Macrobenchmark results: {results}') + + if os.getenv('CI') is None: + _logger.info('Running locally. Results upload skipped.') + return + # Upload successful measurements to the metric service measurements = [] for result in results: @@ -130,24 +145,29 @@ class MacrobenchmarkTest: """Builds the test based on configurations and runs the test on FTL.""" def __init__( self, - sdk_name, test_app_config, artifact_versions, + repo_root_dir, + test_dir, logger=_logger ): - self.sdk_name = sdk_name self.test_app_config = test_app_config self.artifact_versions = artifact_versions - self.logger = MacrobenchmarkLoggerAdapter(logger, sdk_name) - self.test_app_dir = os.path.join('test-apps', test_app_config['name']) + self.repo_root_dir = repo_root_dir + self.test_dir = test_dir + self.logger = MacrobenchmarkLoggerAdapter(logger, test_app_config['sdk']) + self.test_app_dir = os.path.join(test_dir, test_app_config['name']) self.test_results_bucket = 'fireescape-benchmark-results' self.test_results_dir = str(uuid.uuid4()) self.gcs_client = storage.Client() - async def run(self): - """Starts the workflow of src creation, apks assembly, FTL testing and results upload.""" + async def build(self): + """Creates test app project and assembles app and test apks.""" await self._create_benchmark_projects() await self._assemble_benchmark_apks() + + async def test(self): + """Runs benchmark tests on FTL and fetches FTL results from GCS.""" await self._execute_benchmark_tests() return await self._aggregate_benchmark_results() @@ -155,26 +175,33 @@ async def _create_benchmark_projects(self): app_name = self.test_app_config['name'] self.logger.info(f'Creating test app "{app_name}"...') - mustache_context = await self._prepare_mustache_context() + self.logger.info(f'Copying project template files into "{self.test_app_dir}"...') + template_dir = os.path.join(self.repo_root_dir, 'health-metrics/benchmark/template') + shutil.copytree(template_dir, self.test_app_dir) + + self.logger.info(f'Copying gradle wrapper binary into "{self.test_app_dir}"...') + shutil.copy(os.path.join(self.test_dir, 'gradlew'), self.test_app_dir) + shutil.copy(os.path.join(self.test_dir, 'gradlew.bat'), self.test_app_dir) + shutil.copytree(os.path.join(self.test_dir, 'gradle'), os.path.join(self.test_app_dir, 'gradle')) - shutil.copytree('template', self.test_app_dir) with chdir(self.test_app_dir): + mustache_context = await self._prepare_mustache_context() renderer = pystache.Renderer() mustaches = glob.glob('**/*.mustache', recursive=True) for mustache in mustaches: + self.logger.info(f'Processing template file: {mustache}') result = renderer.render_path(mustache, mustache_context) - original_name = mustache[:-9] # TODO(yifany): mustache.removesuffix('.mustache') + original_name = mustache.removesuffix('.mustache') with open(original_name, 'w') as file: file.write(result) async def _assemble_benchmark_apks(self): - executable = './gradlew' - args = ['assemble', 'assembleAndroidTest', '--project-dir', self.test_app_dir] - await self._exec_subprocess(executable, args) + with chdir(self.test_app_dir): + await self._exec_subprocess('./gradlew', ['assemble']) async def _execute_benchmark_tests(self): - app_apk_path = glob.glob(f'{self.test_app_dir}/app/**/*.apk', recursive=True)[0] - test_apk_path = glob.glob(f'{self.test_app_dir}/benchmark/**/*.apk', recursive=True)[0] + app_apk_path = glob.glob(f'{self.test_app_dir}/**/app-benchmark.apk', recursive=True)[0] + test_apk_path = glob.glob(f'{self.test_app_dir}/**/macrobenchmark-benchmark.apk', recursive=True)[0] self.logger.info(f'App apk: {app_apk_path}') self.logger.info(f'Test apk: {test_apk_path}') @@ -189,7 +216,7 @@ async def _execute_benchmark_tests(self): args += ['--type', 'instrumentation'] args += ['--app', app_apk_path] args += ['--test', test_apk_path] - args += ['--device', 'model=redfin,version=30,locale=en,orientation=portrait'] + args += ['--device', 'model=oriole,version=32,locale=en,orientation=portrait'] args += ['--directories-to-pull', '/sdcard/Download'] args += ['--results-bucket', f'gs://{self.test_results_bucket}'] args += ['--results-dir', self.test_results_dir] @@ -200,19 +227,13 @@ async def _execute_benchmark_tests(self): await self._exec_subprocess(executable, args) async def _prepare_mustache_context(self): - app_name = self.test_app_config['name'] - mustache_context = { - 'plugins': [], + 'm2repository': os.path.join(self.repo_root_dir, 'build/m2repository'), + 'plugins': self.test_app_config.get('plugins', []), + 'traces': self.test_app_config.get('traces', []), 'dependencies': [], } - if app_name != 'baseline': - mustache_context['plugins'].append('com.google.gms.google-services') - - if 'plugins' in self.test_app_config: - mustache_context['plugins'].extend(self.test_app_config['plugins']) - if 'dependencies' in self.test_app_config: for dep in self.test_app_config['dependencies']: if '@' in dep: @@ -234,9 +255,9 @@ async def _aggregate_benchmark_results(self): for benchmark in benchmarks: method = benchmark['name'] clazz = benchmark['className'].split('.')[-1] - runs = benchmark['metrics']['startupMs']['runs'] + runs = benchmark['metrics']['timeToInitialDisplayMs']['runs'] results.append({ - 'sdk': self.sdk_name, + 'sdk': self.test_app_config['sdk'], 'device': device, 'name': f'{clazz}.{method}', 'min': min(runs), diff --git a/health-metrics/README.md b/health-metrics/README.md index bd8cb53a40c..b390ec2e938 100644 --- a/health-metrics/README.md +++ b/health-metrics/README.md @@ -12,4 +12,14 @@ Refer to [README.md](apk-size/README.md) in the subdirectory `apk-size` for more ## App startup time -**TODO(yifany)**: Add more details once the measurement tools and infrastructure is ready. +Firebase runs during different +[app lifecycle](https://d.android.com/guide/components/activities/process-lifecycle) +phases, and contributes to the overall +[app startup time](https://d.android.com/topic/performance/vitals/launch-time) +in many ways. + +We are currently using +[benchmarking](https://d.android.com/topic/performance/benchmarking/benchmarking-overview) +and [tracing](https://d.android.com/topic/performance/tracing) to measure its +latency impact. Refer to [README.md](benchmark/README.md) in the subdirectory +`benchmark` for more details. diff --git a/health-metrics/benchmark/README.md b/health-metrics/benchmark/README.md new file mode 100644 index 00000000000..5cffaf1532a --- /dev/null +++ b/health-metrics/benchmark/README.md @@ -0,0 +1,112 @@ +# Benchmark + +This directory contains the benchmark test apps used for measuring latency for +initializing Firebase Android SDKs during app startup. + +## Test app configurations + +[config.yaml](config.yaml) contains a list of configuration blocks for +building a macrobenchmark test app for each of the Firebase Android SDKs. +If not all of them are required, comment out irrelevant ones for faster build +and test time. + +## Run benchmark tests + +### Prerequisite + +1. `fireci` CLI tool + + Refer to its [readme](../../ci/fireci/README.md) for how to install it. + +1. `google-services.json` + + Download it from the Firebase project + [`fireescape-integ-tests`](https://firebase.corp.google.com/u/0/project/fireescape-integ-tests) + to the directory `./template/app`. + +1. Authentication to Google Cloud + + Authentication is required by Google Cloud SDK and Google Cloud Storage + client library used in the benchmark tests. + + One simple way is to configure it is to set an environment variable + `GOOGLE_APPLICATION_CREDENTIALS` to a service account key file. However, + please refer to the official Google Cloud + [doc](https://cloud.google.com/docs/authentication) for full guidance on + authentication. + +### Run benchmark tests locally + +1. Build all test apps by running below command in the root + directory `firebase-android-sdk`: + + ```shell + fireci macrobenchmark --build-only + ``` + +1. [Connect an Android device to the computer](https://d.android.com/studio/run/device) + +1. Locate the temporary test apps directory from the log, for example: + + - on linux: `/tmp/benchmark-test-*/` + - on macos: `/var/folders/**/benchmark-test-*/` + +1. Start the benchmark tests from CLI or Android Studio: + + - CLI + + Run below command in the above test app project directory + + ``` + ./gradlew :macrobenchmark:connectedCheck + ``` + + - Android Studio + + 1. Import the project (e.g. `**/benchmark-test-*/firestore`) into Android Studio + 1. Start the benchmark test by clicking gutter icons in the file `BenchmarkTest.kt` + +1. Inspect the benchmark test results: + + - CLI + + Result files are created in `/macrobenchmark/build/outputs/`: + + - `*-benchmarkData.json` contains metric aggregates + - `*.perfetto-trace` are the raw trace files + + Additionally, upload `.perfetto-trace` files to + [Perfetto Trace Viewer](https://ui.perfetto.dev/) to visualize all traces. + + - Android Studio + + Test results are displayed directly in the "Run" tool window, including + + - macrobenchmark built-in metrics + - duration of custom traces + - links to trace files that can be visualized within the IDE + + Alternatively, same set of result files are produced at the same output + location as invoking tests from CLI, which can be used for inspection. + +### Run benchmark tests on Firebase Test Lab + +Build and run all tests on FTL by running below command in the root +directory `firebase-android-sdk`: + +``` +fireci macrobenchmark +``` + +Alternatively, it is possible to build all test apps via steps described in +[Running benchmark tests locally](#running-benchmark-tests-locally) +and manually +[run tests on FTL with `gcloud` CLI ](https://firebase.google.com/docs/test-lab/android/command-line#running_your_instrumentation_tests). + +Aggregated benchmark results are displayed in the log. The log also +contains links to FTL result pages and result files on Google Cloud Storage. + +## Toolchains + +- Gradle 7.5.1 +- Android Gradle Plugin 7.2.2 diff --git a/health-metrics/benchmark/config.yaml b/health-metrics/benchmark/config.yaml new file mode 100644 index 00000000000..8852965302e --- /dev/null +++ b/health-metrics/benchmark/config.yaml @@ -0,0 +1,72 @@ +# Configurations for tracing test apps construction. +# +# Note: +# - One SDK may contain multiple test apps +# - Common plugins and traces are applied to all test apps during runtime +# - Test apps can also define their additional gradle plugins and custom traces, e.g. +# +# test-apps: +# - sdk: firebase-crashlytics +# name: crashlytics-1 +# plugins: [com.google.firebase.] +# traces: [crashlytics-custom-trace] +# +# - sdk: firebase-crashlytics +# name: crashlytics-2 +# ...... +# + +common-plugins: [com.google.gms.google-services] + +common-traces: [Firebase, ComponentDiscovery, Runtime] + +test-apps: + - sdk: firebase-config + name: config + dependencies: [com.google.firebase:firebase-config-ktx] + - sdk: firebase-common + name: common + dependencies: [com.google.firebase:firebase-common] + - sdk: firebase-crashlytics + name: crash + dependencies: [com.google.firebase:firebase-crashlytics-ktx] + plugins: [com.google.firebase.crashlytics] + - sdk: firebase-database + name: database + dependencies: [com.google.firebase:firebase-database-ktx] + - sdk: firebase-dynamic-links + name: fdl + dependencies: [com.google.firebase:firebase-dynamic-links-ktx] + - sdk: firebase-firestore + name: firestore + dependencies: [com.google.firebase:firebase-firestore-ktx] + - sdk: firebase-functions + name: functions + dependencies: [com.google.firebase:firebase-functions-ktx] + # TODO(yifany): disable temporarily due to errors of duplicate class and gradle crash + # - sdk: firebase-inappmessaging-display + # name: fiam + # dependencies: + # - com.google.firebase:firebase-analytics-ktx@18.0.3 + # - com.google.firebase:firebase-inappmessaging-ktx + # - com.google.firebase:firebase-inappmessaging-display-ktx + - sdk: firebase-messaging + name: message + dependencies: [com.google.firebase:firebase-messaging-ktx] + - sdk: firebase-perf + name: perf + dependencies: [com.google.firebase:firebase-perf-ktx] + plugins: [com.google.firebase.firebase-perf] + - sdk: firebase-storage + name: stroage + dependencies: [com.google.firebase:firebase-storage-ktx] + + +# TODO(yifany): google3 sdks, customizing FTL devices +# auth +# analytics +# combined +# - crashlytics + analytics +# - crashlytics + fireperf +# - auth + firestore +# - ... diff --git a/health-metrics/macrobenchmark/template/app/build.gradle.mustache b/health-metrics/benchmark/template/app/build.gradle.mustache similarity index 76% rename from health-metrics/macrobenchmark/template/app/build.gradle.mustache rename to health-metrics/benchmark/template/app/build.gradle.mustache index 73537a6300b..5dbc037af99 100644 --- a/health-metrics/macrobenchmark/template/app/build.gradle.mustache +++ b/health-metrics/benchmark/template/app/build.gradle.mustache @@ -14,28 +14,28 @@ plugins { id 'com.android.application' - id 'kotlin-android' + id 'org.jetbrains.kotlin.android' {{#plugins}} id '{{.}}' {{/plugins}} } android { - compileSdkVersion 30 - buildToolsVersion '30.0.3' + compileSdkVersion 32 defaultConfig { - applicationId 'com.google.firebase.macrobenchmark' + applicationId 'com.google.firebase.benchmark' minSdkVersion 29 - targetSdkVersion 30 + targetSdkVersion 32 versionCode 1 - versionName "1.0" + versionName '1.0' testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } buildTypes { - release { + benchmark { + debuggable false minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' @@ -64,12 +64,13 @@ dependencies { implementation '{{key}}:{{version}}' {{/dependencies}} - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.5.0' - implementation 'androidx.appcompat:appcompat:1.3.0' - implementation 'com.google.android.material:material:1.3.0' - implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation 'androidx.tracing:tracing-ktx:1.1.0' + + implementation 'androidx.core:core-ktx:1.8.0' + implementation 'androidx.appcompat:appcompat:1.5.0' + implementation 'com.google.android.material:material:1.6.1' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } diff --git a/health-metrics/macrobenchmark/template/app/proguard-rules.pro b/health-metrics/benchmark/template/app/proguard-rules.pro similarity index 100% rename from health-metrics/macrobenchmark/template/app/proguard-rules.pro rename to health-metrics/benchmark/template/app/proguard-rules.pro diff --git a/health-metrics/benchmark/template/app/src/main/AndroidManifest.xml b/health-metrics/benchmark/template/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000000..400075eb9c4 --- /dev/null +++ b/health-metrics/benchmark/template/app/src/main/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + diff --git a/health-metrics/macrobenchmark/template/app/src/main/java/com/google/firebase/benchmark/MainActivity.kt b/health-metrics/benchmark/template/app/src/main/java/com/google/firebase/benchmark/MainActivity.kt similarity index 100% rename from health-metrics/macrobenchmark/template/app/src/main/java/com/google/firebase/benchmark/MainActivity.kt rename to health-metrics/benchmark/template/app/src/main/java/com/google/firebase/benchmark/MainActivity.kt diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/health-metrics/benchmark/template/app/src/main/res/drawable-v24/ic_launcher_foreground.xml similarity index 99% rename from health-metrics/macrobenchmark/template/app/src/main/res/drawable-v24/ic_launcher_foreground.xml rename to health-metrics/benchmark/template/app/src/main/res/drawable-v24/ic_launcher_foreground.xml index 2b068d11462..7706ab9e6d4 100644 --- a/health-metrics/macrobenchmark/template/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +++ b/health-metrics/benchmark/template/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -27,4 +27,4 @@ android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z" android:strokeWidth="1" android:strokeColor="#00000000" /> - \ No newline at end of file + diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/drawable/ic_launcher_background.xml b/health-metrics/benchmark/template/app/src/main/res/drawable/ic_launcher_background.xml similarity index 100% rename from health-metrics/macrobenchmark/template/app/src/main/res/drawable/ic_launcher_background.xml rename to health-metrics/benchmark/template/app/src/main/res/drawable/ic_launcher_background.xml diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/layout/activity_main.xml b/health-metrics/benchmark/template/app/src/main/res/layout/activity_main.xml similarity index 79% rename from health-metrics/macrobenchmark/template/app/src/main/res/layout/activity_main.xml rename to health-metrics/benchmark/template/app/src/main/res/layout/activity_main.xml index 4fc244418b5..c75d0576c09 100644 --- a/health-metrics/macrobenchmark/template/app/src/main/res/layout/activity_main.xml +++ b/health-metrics/benchmark/template/app/src/main/res/layout/activity_main.xml @@ -11,8 +11,8 @@ android:layout_height="wrap_content" android:text="Hello World!" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintLeft_toLeftOf="parent" - app:layout_constraintRight_toRightOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> - \ No newline at end of file + diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/health-metrics/benchmark/template/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml similarity index 93% rename from health-metrics/macrobenchmark/template/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml rename to health-metrics/benchmark/template/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index eca70cfe52e..6b78462d615 100644 --- a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/health-metrics/benchmark/template/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -2,4 +2,4 @@ - \ No newline at end of file + diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/health-metrics/benchmark/template/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml similarity index 93% rename from health-metrics/macrobenchmark/template/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml rename to health-metrics/benchmark/template/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml index eca70cfe52e..6b78462d615 100644 --- a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/health-metrics/benchmark/template/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -2,4 +2,4 @@ - \ No newline at end of file + diff --git a/health-metrics/benchmark/template/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/health-metrics/benchmark/template/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 00000000000..c209e78ecd3 Binary files /dev/null and b/health-metrics/benchmark/template/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/health-metrics/benchmark/template/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/health-metrics/benchmark/template/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 00000000000..b2dfe3d1ba5 Binary files /dev/null and b/health-metrics/benchmark/template/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/health-metrics/benchmark/template/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/health-metrics/benchmark/template/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 00000000000..4f0f1d64e58 Binary files /dev/null and b/health-metrics/benchmark/template/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/health-metrics/benchmark/template/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/health-metrics/benchmark/template/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 00000000000..62b611da081 Binary files /dev/null and b/health-metrics/benchmark/template/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/health-metrics/benchmark/template/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/health-metrics/benchmark/template/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 00000000000..948a3070fe3 Binary files /dev/null and b/health-metrics/benchmark/template/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/health-metrics/benchmark/template/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/health-metrics/benchmark/template/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 00000000000..1b9a6956b3a Binary files /dev/null and b/health-metrics/benchmark/template/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/health-metrics/benchmark/template/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/health-metrics/benchmark/template/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 00000000000..28d4b77f9f0 Binary files /dev/null and b/health-metrics/benchmark/template/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/health-metrics/benchmark/template/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/health-metrics/benchmark/template/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 00000000000..9287f508362 Binary files /dev/null and b/health-metrics/benchmark/template/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/health-metrics/benchmark/template/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/health-metrics/benchmark/template/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 00000000000..aa7d6427e6f Binary files /dev/null and b/health-metrics/benchmark/template/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/health-metrics/benchmark/template/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/health-metrics/benchmark/template/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 00000000000..9126ae37cbc Binary files /dev/null and b/health-metrics/benchmark/template/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/values-night/themes.xml b/health-metrics/benchmark/template/app/src/main/res/values-night/themes.xml similarity index 86% rename from health-metrics/macrobenchmark/template/app/src/main/res/values-night/themes.xml rename to health-metrics/benchmark/template/app/src/main/res/values-night/themes.xml index 88f1c721163..78ada11fae6 100644 --- a/health-metrics/macrobenchmark/template/app/src/main/res/values-night/themes.xml +++ b/health-metrics/benchmark/template/app/src/main/res/values-night/themes.xml @@ -1,6 +1,6 @@ - - \ No newline at end of file + diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/values/colors.xml b/health-metrics/benchmark/template/app/src/main/res/values/colors.xml similarity index 96% rename from health-metrics/macrobenchmark/template/app/src/main/res/values/colors.xml rename to health-metrics/benchmark/template/app/src/main/res/values/colors.xml index f8c6127d327..ca1931bca99 100644 --- a/health-metrics/macrobenchmark/template/app/src/main/res/values/colors.xml +++ b/health-metrics/benchmark/template/app/src/main/res/values/colors.xml @@ -7,4 +7,4 @@ #FF018786 #FF000000 #FFFFFFFF - \ No newline at end of file + diff --git a/health-metrics/benchmark/template/app/src/main/res/values/strings.xml b/health-metrics/benchmark/template/app/src/main/res/values/strings.xml new file mode 100644 index 00000000000..2acaa64f542 --- /dev/null +++ b/health-metrics/benchmark/template/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + benchmark + diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/values/themes.xml b/health-metrics/benchmark/template/app/src/main/res/values/themes.xml similarity index 86% rename from health-metrics/macrobenchmark/template/app/src/main/res/values/themes.xml rename to health-metrics/benchmark/template/app/src/main/res/values/themes.xml index 2bbfc467c2c..11866afe933 100644 --- a/health-metrics/macrobenchmark/template/app/src/main/res/values/themes.xml +++ b/health-metrics/benchmark/template/app/src/main/res/values/themes.xml @@ -1,6 +1,6 @@ - - \ No newline at end of file + diff --git a/health-metrics/benchmark/template/app/src/main/res/xml/backup_rules.xml b/health-metrics/benchmark/template/app/src/main/res/xml/backup_rules.xml new file mode 100644 index 00000000000..148c18b6593 --- /dev/null +++ b/health-metrics/benchmark/template/app/src/main/res/xml/backup_rules.xml @@ -0,0 +1,13 @@ + + + + diff --git a/health-metrics/benchmark/template/app/src/main/res/xml/data_extraction_rules.xml b/health-metrics/benchmark/template/app/src/main/res/xml/data_extraction_rules.xml new file mode 100644 index 00000000000..0c4f95cab91 --- /dev/null +++ b/health-metrics/benchmark/template/app/src/main/res/xml/data_extraction_rules.xml @@ -0,0 +1,19 @@ + + + + + + + diff --git a/health-metrics/benchmark/template/build.gradle b/health-metrics/benchmark/template/build.gradle new file mode 100644 index 00000000000..a83d229b243 --- /dev/null +++ b/health-metrics/benchmark/template/build.gradle @@ -0,0 +1,28 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +plugins { + id 'com.android.application' version '7.2.2' apply false + id 'com.android.library' version '7.2.2' apply false + id 'com.android.test' version '7.2.2' apply false + id 'org.jetbrains.kotlin.android' version '1.7.10' apply false + + id 'com.google.gms.google-services' version '4.3.13' apply false + id 'com.google.firebase.crashlytics' version '2.9.1' apply false + id 'com.google.firebase.firebase-perf' version '1.4.1' apply false +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/health-metrics/macrobenchmark/template/gradle.properties b/health-metrics/benchmark/template/gradle.properties similarity index 96% rename from health-metrics/macrobenchmark/template/gradle.properties rename to health-metrics/benchmark/template/gradle.properties index a7d19a63475..a90756bf7d4 100644 --- a/health-metrics/macrobenchmark/template/gradle.properties +++ b/health-metrics/benchmark/template/gradle.properties @@ -20,7 +20,7 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx512m -Xms256m -Dfile.encoding=UTF-8 +org.gradle.jvmargs=-Xmx1024m -Xms512m -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects diff --git a/health-metrics/macrobenchmark/template/benchmark/build.gradle b/health-metrics/benchmark/template/macrobenchmark/build.gradle similarity index 52% rename from health-metrics/macrobenchmark/template/benchmark/build.gradle rename to health-metrics/benchmark/template/macrobenchmark/build.gradle index aacb27f8539..be80bc79f06 100644 --- a/health-metrics/macrobenchmark/template/benchmark/build.gradle +++ b/health-metrics/benchmark/template/macrobenchmark/build.gradle @@ -13,48 +13,50 @@ // limitations under the License. plugins { - id 'com.android.library' - id 'kotlin-android' + id 'com.android.test' + id 'org.jetbrains.kotlin.android' } android { - compileSdkVersion 30 - buildToolsVersion '30.0.3' + compileSdkVersion 32 + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } defaultConfig { - minSdkVersion 29 - targetSdkVersion 30 - versionCode 1 - versionName '1.0' + minSdk 29 + targetSdk 32 testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + benchmark { + debuggable = true + signingConfig = debug.signingConfig + matchingFallbacks = ["release"] } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = '1.8' - } + targetProjectPath = ":app" + experimentalProperties["android.experimental.self-instrumenting"] = true } dependencies { - androidTestImplementation 'androidx.benchmark:benchmark-macro-junit4:1.1.0-alpha02' - - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.core:core-ktx:1.5.0' - implementation 'androidx.appcompat:appcompat:1.3.0' - implementation 'com.google.android.material:material:1.3.0' - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' + implementation 'androidx.test.ext:junit:1.1.3' + implementation 'androidx.test.espresso:espresso-core:3.4.0' + implementation 'androidx.test.uiautomator:uiautomator:2.2.0' + implementation 'androidx.benchmark:benchmark-macro-junit4:1.1.0' +} + +androidComponents { + beforeVariants(selector().all()) { + enabled = buildType == "benchmark" + } } diff --git a/health-metrics/macrobenchmark/template/benchmark/proguard-rules.pro b/health-metrics/benchmark/template/macrobenchmark/proguard-rules.pro similarity index 100% rename from health-metrics/macrobenchmark/template/benchmark/proguard-rules.pro rename to health-metrics/benchmark/template/macrobenchmark/proguard-rules.pro diff --git a/health-metrics/benchmark/template/macrobenchmark/src/main/AndroidManifest.xml b/health-metrics/benchmark/template/macrobenchmark/src/main/AndroidManifest.xml new file mode 100644 index 00000000000..5b21eea1a7f --- /dev/null +++ b/health-metrics/benchmark/template/macrobenchmark/src/main/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + + + + diff --git a/health-metrics/benchmark/template/macrobenchmark/src/main/java/com/google/firebase/macrobenchmark/BenchmarkTest.kt.mustache b/health-metrics/benchmark/template/macrobenchmark/src/main/java/com/google/firebase/macrobenchmark/BenchmarkTest.kt.mustache new file mode 100644 index 00000000000..4fa5af3546e --- /dev/null +++ b/health-metrics/benchmark/template/macrobenchmark/src/main/java/com/google/firebase/macrobenchmark/BenchmarkTest.kt.mustache @@ -0,0 +1,48 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.firebase.macrobenchmark + +import androidx.benchmark.macro.ExperimentalMetricApi +import androidx.benchmark.macro.StartupMode +import androidx.benchmark.macro.StartupTimingMetric +import androidx.benchmark.macro.TraceSectionMetric +import androidx.benchmark.macro.junit4.MacrobenchmarkRule +import androidx.test.ext.junit.runners.AndroidJUnit4 +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(AndroidJUnit4::class) +class StartupBenchmark { + @get:Rule + val benchmarkRule = MacrobenchmarkRule() + + @OptIn(ExperimentalMetricApi::class) + @Test + fun startup() = benchmarkRule.measureRepeated( + packageName = "com.google.firebase.benchmark", + metrics = listOf( + StartupTimingMetric(), + {{#traces}} + TraceSectionMetric("{{.}}"), + {{/traces}} + ), + iterations = 5, + startupMode = StartupMode.COLD + ) { + pressHome() + startActivityAndWait() + } +} diff --git a/health-metrics/macrobenchmark/template/settings.gradle b/health-metrics/benchmark/template/settings.gradle.mustache similarity index 60% rename from health-metrics/macrobenchmark/template/settings.gradle rename to health-metrics/benchmark/template/settings.gradle.mustache index 3c1a05b94ef..2428ba1c912 100644 --- a/health-metrics/macrobenchmark/template/settings.gradle +++ b/health-metrics/benchmark/template/settings.gradle.mustache @@ -12,6 +12,25 @@ // See the License for the specific language governing permissions and // limitations under the License. -rootProject.name = 'macrobenchmark' +pluginManagement { + repositories { + gradlePluginPortal() + google() + mavenCentral() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + + maven { + url '{{m2repository}}' + } + } +} + +rootProject.name = 'benchmark' include ':app' -include ':benchmark' +include ':macrobenchmark' diff --git a/health-metrics/macrobenchmark/config.yaml b/health-metrics/macrobenchmark/config.yaml deleted file mode 100644 index 791885dd9ef..00000000000 --- a/health-metrics/macrobenchmark/config.yaml +++ /dev/null @@ -1,74 +0,0 @@ -baseline: - name: baseline - -firebase-config: - name: config - dependencies: - - com.google.firebase:firebase-config-ktx - -firebase-common: - name: common - dependencies: - - com.google.firebase:firebase-common - -firebase-crashlytics: - name: crash - dependencies: - - com.google.firebase:firebase-crashlytics-ktx - plugins: - - com.google.firebase.crashlytics - -firebase-database: - name: database - dependencies: - - com.google.firebase:firebase-database-ktx - -firebase-dynamic-links: - name: dynamiclinks - dependencies: - - com.google.firebase:firebase-dynamic-links-ktx - -firebase-firestore: - name: firestore - dependencies: - - com.google.firebase:firebase-firestore-ktx - -firebase-functions: - name: functions - dependencies: - - com.google.firebase:firebase-functions-ktx - -firebase-inappmessaging-display: - name: inappmessaging - dependencies: - - com.google.firebase:firebase-analytics-ktx@18.0.3 - - com.google.firebase:firebase-inappmessaging-ktx - - com.google.firebase:firebase-inappmessaging-display-ktx - -firebase-messaging: - name: messaging - dependencies: - - com.google.firebase:firebase-messaging-ktx - -firebase-perf: - name: perf - dependencies: - - com.google.firebase:firebase-perf-ktx - plugins: - - com.google.firebase.firebase-perf - -firebase-storage: - name: storage - dependencies: - - com.google.firebase:firebase-storage-ktx - - - -# TODO(yifany): google3 sdks, customizing FTL devices -# auth -# analytics -# combined -# - crashlytics + analytics -# - crashlytics + fireperf -# - auth + firestore -# - ... diff --git a/health-metrics/macrobenchmark/template/app/src/main/AndroidManifest.xml b/health-metrics/macrobenchmark/template/app/src/main/AndroidManifest.xml deleted file mode 100644 index 4920e1c389e..00000000000 --- a/health-metrics/macrobenchmark/template/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-hdpi/ic_launcher.png b/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index a571e60098c..00000000000 Binary files a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-hdpi/ic_launcher_round.png deleted file mode 100644 index 61da551c559..00000000000 Binary files a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-hdpi/ic_launcher_round.png and /dev/null differ diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-mdpi/ic_launcher.png b/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index c41dd285319..00000000000 Binary files a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-mdpi/ic_launcher_round.png deleted file mode 100644 index db5080a7527..00000000000 Binary files a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-mdpi/ic_launcher_round.png and /dev/null differ diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index 6dba46dab19..00000000000 Binary files a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png deleted file mode 100644 index da31a871c8d..00000000000 Binary files a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png and /dev/null differ diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 15ac681720f..00000000000 Binary files a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png deleted file mode 100644 index b216f2d313c..00000000000 Binary files a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index f25a4197447..00000000000 Binary files a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png deleted file mode 100644 index e96783ccce8..00000000000 Binary files a/health-metrics/macrobenchmark/template/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png and /dev/null differ diff --git a/health-metrics/macrobenchmark/template/app/src/main/res/values/strings.xml b/health-metrics/macrobenchmark/template/app/src/main/res/values/strings.xml deleted file mode 100644 index 84d56e22541..00000000000 --- a/health-metrics/macrobenchmark/template/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - macrobenchmark - \ No newline at end of file diff --git a/health-metrics/macrobenchmark/template/benchmark/src/androidTest/AndroidManifest.xml b/health-metrics/macrobenchmark/template/benchmark/src/androidTest/AndroidManifest.xml deleted file mode 100644 index a3d4dd73e80..00000000000 --- a/health-metrics/macrobenchmark/template/benchmark/src/androidTest/AndroidManifest.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/health-metrics/macrobenchmark/template/benchmark/src/androidTest/java/com/google/firebase/benchmark/BenchmarkTest.kt.mustache b/health-metrics/macrobenchmark/template/benchmark/src/androidTest/java/com/google/firebase/benchmark/BenchmarkTest.kt.mustache deleted file mode 100644 index 5b35820fe9b..00000000000 --- a/health-metrics/macrobenchmark/template/benchmark/src/androidTest/java/com/google/firebase/benchmark/BenchmarkTest.kt.mustache +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.google.firebase.benchmark - -import android.content.Intent -import androidx.benchmark.macro.StartupMode -import androidx.benchmark.macro.StartupTimingMetric -import androidx.benchmark.macro.junit4.MacrobenchmarkRule -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.Parameterized - - -@RunWith(Parameterized::class) -class BenchmarkTest(private val startupMode: StartupMode) { - @get:Rule - val benchmarkRule = MacrobenchmarkRule() - - @Test - fun startup() = benchmarkRule.measureRepeated( - packageName = "com.google.firebase.macrobenchmark", - metrics = listOf(StartupTimingMetric()), - iterations = 20, - startupMode = startupMode - ) { - pressHome() - val intent = Intent() - intent.setPackage("com.google.firebase.macrobenchmark") - intent.setAction("com.google.firebase.benchmark.STARTUP_ACTIVITY") - startActivityAndWait(intent) - } - - companion object { - @Parameterized.Parameters(name = "mode={0}") - @JvmStatic - fun parameters(): List> { - return listOf(StartupMode.COLD, StartupMode.WARM, StartupMode.HOT) - .map { arrayOf(it) } - } - } -} diff --git a/health-metrics/macrobenchmark/template/benchmark/src/main/AndroidManifest.xml.mustache b/health-metrics/macrobenchmark/template/benchmark/src/main/AndroidManifest.xml.mustache deleted file mode 100644 index 15cff250146..00000000000 --- a/health-metrics/macrobenchmark/template/benchmark/src/main/AndroidManifest.xml.mustache +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/health-metrics/macrobenchmark/template/build.gradle b/health-metrics/macrobenchmark/template/build.gradle deleted file mode 100644 index ba1e309c38a..00000000000 --- a/health-metrics/macrobenchmark/template/build.gradle +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -buildscript { - ext.kotlin_version = "1.5.0" - repositories { - google() - mavenCentral() - } - dependencies { - classpath "com.android.tools.build:gradle:4.2.0" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - classpath 'com.google.gms:google-services:4.3.5' - - // Add the Crashlytics Gradle plugin (be sure to add version - // 2.0.0 or later if you built your app with Android Studio 4.1). - classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2' - - // Add the dependency for the Performance Monitoring plugin - classpath 'com.google.firebase:perf-plugin:1.3.5' // Performance Monitoring plugin - } -} - -allprojects { - repositories { - google() - mavenCentral() - - maven { - url rootProject.file('../../../../build/m2repository') - } - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -}