1
1
# Benchmark
2
2
3
3
This directory contains the benchmark test apps used for measuring latency for
4
- different Firebase Android SDKs during app startup.
4
+ initializing Firebase Android SDKs during app startup.
5
5
6
- ## Usage
6
+ ## Test app configurations
7
+
8
+ [ config.yaml] ( config.yaml ) contains a list of configuration blocks for
9
+ building a macrobenchmark test app for each of the Firebase Android SDKs.
10
+ If not all of them are required, comment out irrelevant ones for faster build
11
+ and test time.
12
+
13
+ ** Note** : An empty Android app (named ` baseline ` ) will be created during runtime
14
+ for baseline comparison, even though it is not listed in
15
+ [ config.yaml] ( config.yaml ) . This app can also be used as a skeleton for
16
+ setting up a more complex benchmark testing app.
17
+
18
+ ## Run benchmark tests
7
19
8
20
### Prerequisite
9
21
10
22
1 . ` fireci ` CLI tool
11
23
12
- Refer to the [ readme] ( ../../ci/fireci/README.md ) for how to install it.
24
+ Refer to its [ readme] ( ../../ci/fireci/README.md ) for how to install it.
13
25
14
26
1 . ` google-services.json `
15
27
16
- Download it from Firebase project
28
+ Download it from the Firebase project
17
29
[ ` fireescape-integ-tests ` ] ( https://firebase.corp.google.com/u/0/project/fireescape-integ-tests )
18
- to the directory ` firebase-android-sdk/health-metrics/benchmark /template/app` .
30
+ to the directory ` . /template/app` .
19
31
20
32
1 . Authentication to Google Cloud
21
33
22
- Authentication is required by Google Cloud SDK and Cloud Storage client
23
- library used in the benchmark tests.
34
+ Authentication is required by Google Cloud SDK and Google Cloud Storage
35
+ client library used in the benchmark tests.
24
36
25
37
One simple way is to configure it is to set an environment variable
26
38
` GOOGLE_APPLICATION_CREDENTIALS ` to a service account key file. However,
27
39
please refer to the official Google Cloud
28
40
[ doc] ( https://cloud.google.com/docs/authentication ) for full guidance on
29
41
authentication.
30
42
31
- ### Running benchmark tests locally
43
+ ### Run benchmark tests locally
32
44
33
45
1 . Build all test apps by running below command in the root
34
46
directory ` firebase-android-sdk ` :
@@ -41,25 +53,48 @@ different Firebase Android SDKs during app startup.
41
53
42
54
1 . Locate the temporary test apps directory from the log, for example:
43
55
44
- - on linux: ` /tmp/benchmark-test-run- */ `
45
- - on macos: ` /var/folders/**/benchmark-test-run- */ `
56
+ - on linux: ` /tmp/benchmark-test-*/ `
57
+ - on macos: ` /var/folders/**/benchmark-test-*/ `
46
58
47
- 1 . Start the benchmark tests from Android Studio or CLI:
59
+ 1 . Start the benchmark tests from CLI or Android Studio:
60
+
61
+ - CLI
62
+
63
+ Run below command in the above test app project directory
64
+
65
+ ```
66
+ ./gradlew :macrobenchmark:connectedCheck
67
+ ```
48
68
49
69
- Android Studio
50
70
51
- 1 . Import the project (e.g. ` **/benchmark-test-run-*/firestore ` ) into Android Studio
52
- 1 . Start the benchmark test by clicking gutter icon in the file ` BenchmarkTest.kt `
71
+ 1. Import the project (e.g. `**/benchmark-test-*/firestore`) into Android Studio
72
+ 1. Start the benchmark test by clicking gutter icons in the file `BenchmarkTest.kt`
73
+
74
+ 1. Inspect the benchmark test results:
53
75
54
76
- CLI
55
77
56
- 1 . Run below command in the test app project directory
78
+ Result files are created in `< test- app-dir>/macrobenchmark/build/outputs/`:
57
79
58
- ```
59
- ../gradlew :macrobenchmark:connectedCheck
60
- ```
80
+ - `*-benchmarkData.json` contains metric aggregates
81
+ - `*.perfetto-trace` are the raw trace files
61
82
62
- ### Running benchmark tests on Firebase Test Lab
83
+ Additionally, upload `.perfetto-trace` files to
84
+ [Perfetto Trace Viewer](https://ui.perfetto.dev/) to visualize all traces.
85
+
86
+ - Android Studio
87
+
88
+ Test results are displayed directly in the "Run" tool window, including
89
+
90
+ - macrobenchmark built-in metrics
91
+ - duration of custom traces
92
+ - links to trace files that can be visualized within the IDE
93
+
94
+ Alternatively, same set of result files are produced at the same output
95
+ location as invoking tests from CLI, which can be used for inspection.
96
+
97
+ ### Run benchmark tests on Firebase Test Lab
63
98
64
99
Build and run all tests on FTL by running below command in the root
65
100
directory `firebase-android-sdk`:
@@ -68,4 +103,15 @@ directory `firebase-android-sdk`:
68
103
fireci macrobenchmark
69
104
```
70
105
71
- ### Examining benchmark test results
106
+ Alternatively, it is possible to build all test apps via steps described in
107
+ [Running benchmark tests locally](#running-benchmark-tests-locally)
108
+ and manually
109
+ [run tests on FTL with `gcloud` CLI ](https://firebase.google.com/docs/test-lab/android/command-line#running_your_instrumentation_tests).
110
+
111
+ Aggregated benchmark results are displayed in the log. The log also
112
+ contains links to FTL result pages and result files on Google Cloud Storage.
113
+
114
+ ## Toolchains
115
+
116
+ - Gradle 7.5.1
117
+ - Android Gradle Plugin 7.2.2
0 commit comments