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

Feature/benchmark #3319

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ android {
initWith debug
applicationIdSuffix ".test"
}
benchmark {
signingConfig signingConfigs.debug
matchingFallbacks = ['debug']
debuggable false
}
}

configurations {
Expand Down
62 changes: 35 additions & 27 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
Expand All @@ -24,6 +26,12 @@
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />

<queries>
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
</queries>

<application
android:name=".MixinApp"
android:allowBackup="false"
Expand All @@ -40,6 +48,10 @@
android:theme="@style/AppTheme"
tools:ignore="LockedOrientationActivity,UnusedAttribute"
tools:replace="allowBackup">
<profileable
android:shell="true"
tools:targetApi="29" />

<activity
android:name=".ui.home.MainActivity"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
Expand All @@ -50,6 +62,7 @@
android:windowSoftInputMode="stateUnchanged|stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

Expand All @@ -71,18 +84,18 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="mixin"/>
<data android:host="codes"/>
<data android:host="pay"/>
<data android:host="users"/>
<data android:host="apps"/>
<data android:host="transfer"/>
<data android:host="device"/>
<data android:host="send"/>
<data android:host="withdrawal"/>
<data android:host="address"/>
<data android:host="snapshots"/>
<data android:host="conversations"/>
<data android:scheme="mixin" />
<data android:host="codes" />
<data android:host="pay" />
<data android:host="users" />
<data android:host="apps" />
<data android:host="transfer" />
<data android:host="device" />
<data android:host="send" />
<data android:host="withdrawal" />
<data android:host="address" />
<data android:host="snapshots" />
<data android:host="conversations" />
</intent-filter>
</activity>
<activity
Expand Down Expand Up @@ -149,6 +162,7 @@
android:targetActivity=".ui.forward.ForwardActivity">
<intent-filter>
<action android:name="android.intent.action.SEND" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="text/plain" />
Expand All @@ -159,6 +173,7 @@
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="image/*" />
Expand Down Expand Up @@ -299,7 +314,8 @@
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustPan" />
<activity android:name=".ui.tip.TipActivity"
<activity
android:name=".ui.tip.TipActivity"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar" />
Expand Down Expand Up @@ -335,10 +351,10 @@
android:permission="android.permission.BIND_JOB_SERVICE" />
<service
android:name=".webrtc.VoiceCallService"
android:foregroundServiceType="microphone"/>
android:foregroundServiceType="microphone" />
<service
android:name=".webrtc.GroupCallService"
android:foregroundServiceType="microphone"/>
android:foregroundServiceType="microphone" />
<service
android:name=".job.BlazeMessageService"
android:enabled="true" />
Expand All @@ -362,10 +378,10 @@
android:enabled="true" />
<receiver
android:name=".receiver.TimezoneChangedReceiver"
android:exported="false"
android:enabled="true" >
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.TIMEZONE_CHANGED"/>
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
</intent-filter>
</receiver>

Expand Down Expand Up @@ -400,14 +416,6 @@
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<!-- <meta-data-->
<!-- android:name="com.google.android.gms.car.application"-->
<!-- android:resource="@xml/automotive_app_desc" />-->
</application>

<queries>
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
</queries>
</manifest>
1 change: 1 addition & 0 deletions benchmark/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
52 changes: 52 additions & 0 deletions benchmark/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
plugins {
id 'com.android.test'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'one.mixin.messenger.benchmark'
compileSdk 32

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "1.8"
}

defaultConfig {
minSdk 24
targetSdk 32

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
// This benchmark buildType is used for benchmarking, and should function like your
// release build (for example, with minification on). It's signed with a debug key
// for easy local/CI testing.
benchmark {
debuggable = true
signingConfig = debug.signingConfig
matchingFallbacks = ["release"]
}
}

targetProjectPath = ":app"
experimentalProperties["android.experimental.self-instrumenting"] = true
}

dependencies {
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"
}
}
7 changes: 7 additions & 0 deletions benchmark/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<queries>
<package android:name="one.mixin.messenger" />
</queries>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package one.mixin.messenger.benchmark

import androidx.benchmark.macro.StartupMode
import androidx.benchmark.macro.StartupTimingMetric
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()

@Test
fun startup() = benchmarkRule.measureRepeated(
packageName = "one.mixin.messenger",
metrics = listOf(StartupTimingMetric()),
iterations = 5,
startupMode = StartupMode.COLD
) {
pressHome()
startActivityAndWait()
}
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include ':app'
include ':benchmark'