diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml index 3d010bb..9c72b3a 100644 --- a/.idea/deploymentTargetSelector.xml +++ b/.idea/deploymentTargetSelector.xml @@ -57,6 +57,28 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 02c4aa5..e0b67da 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -10,6 +10,7 @@ diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7022a96..ffbcee3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -29,6 +29,7 @@ lyricist = "1.8.0" material3 = "1.4.0" work = "2.9.1" benchmark = "1.4.1" +uiautomator = "2.3.0" runner = "1.5.2" androidx-test-ext = "1.2.1" timber = "5.0.1" @@ -80,6 +81,8 @@ androidx-work-runtime-ktx = { group = "androidx.work", name = "work-runtime-ktx" androidx-benchmark-junit4 = { group = "androidx.benchmark", name = "benchmark-junit4", version.ref = "benchmark" } androidx-runner = { group = "androidx.test", name = "runner", version.ref = "runner" } androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext" } +androidx-benchmark-macro-junit4 = { group = "androidx.benchmark", name = "benchmark-macro-junit4", version.ref = "benchmark" } +androidx-test-uiautomator = { group = "androidx.test.uiautomator", name = "uiautomator", version.ref = "uiautomator" } timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timber" } kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" } converter-kotlinx-serialization = { module = "com.squareup.retrofit2:converter-kotlinx-serialization", version.ref = "retrofit" } diff --git a/macrobenchmark/.gitignore b/macrobenchmark/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/macrobenchmark/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/macrobenchmark/build.gradle.kts b/macrobenchmark/build.gradle.kts new file mode 100644 index 0000000..2e9c1ff --- /dev/null +++ b/macrobenchmark/build.gradle.kts @@ -0,0 +1,40 @@ +plugins { + alias(libs.plugins.android.test) +} + +android { + namespace = "com.bitcointxoko.gudariwallet.macrobenchmark" + compileSdk = 36 + + defaultConfig { + minSdk = 26 + targetSdk = 36 + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + // because GrapheneOS restricts tracefs access, which is used by Perfetto + // testInstrumentationRunnerArguments["androidx.benchmark.suppressErrors"] = + "DEVICE-TRACING-MISCONFIGURED" + } + + buildTypes { + create("benchmark") { + isDebuggable = true + signingConfig = getByName("debug").signingConfig + matchingFallbacks += listOf("release") + } + } + + targetProjectPath = ":app" + experimentalProperties["android.experimental.self-instrumenting"] = true +} + +dependencies { + implementation(libs.androidx.benchmark.macro.junit4) + implementation(libs.androidx.test.ext.junit) + implementation(libs.androidx.test.uiautomator) +} + +androidComponents { + beforeVariants(selector().all()) { + it.enable = it.buildType == "benchmark" + } +} diff --git a/macrobenchmark/proguard-rules.pro b/macrobenchmark/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/macrobenchmark/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/macrobenchmark/src/androidTest/java/com/bitcointxoko/macrobenchmark/ExampleInstrumentedTest.kt b/macrobenchmark/src/androidTest/java/com/bitcointxoko/macrobenchmark/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..03d126a --- /dev/null +++ b/macrobenchmark/src/androidTest/java/com/bitcointxoko/macrobenchmark/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.bitcointxoko.macrobenchmark + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.bitcointxoko.macrobenchmark", appContext.packageName) + } +} \ No newline at end of file diff --git a/macrobenchmark/src/main/AndroidManifest.xml b/macrobenchmark/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a5918e6 --- /dev/null +++ b/macrobenchmark/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/macrobenchmark/src/main/java/com/bitcointxoko/macrobenchmark/AppStartupBenchmark.kt b/macrobenchmark/src/main/java/com/bitcointxoko/macrobenchmark/AppStartupBenchmark.kt new file mode 100644 index 0000000..ef1029f --- /dev/null +++ b/macrobenchmark/src/main/java/com/bitcointxoko/macrobenchmark/AppStartupBenchmark.kt @@ -0,0 +1,29 @@ +package com.bitcointxoko.macrobenchmark + +import androidx.benchmark.macro.CompilationMode +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 AppStartupBenchmark { + + @get:Rule + val benchmarkRule = MacrobenchmarkRule() + + @Test + fun startupCold() = benchmarkRule.measureRepeated( + packageName = "com.bitcointxoko.gudariwallet", + metrics = listOf(StartupTimingMetric()), + compilationMode = CompilationMode.None(), // cold, no AOT + startupMode = StartupMode.COLD, + iterations = 5, + ) { + pressHome() + startActivityAndWait() + } +} diff --git a/macrobenchmark/src/main/res/drawable/ic_launcher_background.xml b/macrobenchmark/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/macrobenchmark/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macrobenchmark/src/main/res/drawable/ic_launcher_foreground.xml b/macrobenchmark/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..2b068d1 --- /dev/null +++ b/macrobenchmark/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/macrobenchmark/src/main/res/mipmap-anydpi/ic_launcher.xml b/macrobenchmark/src/main/res/mipmap-anydpi/ic_launcher.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/macrobenchmark/src/main/res/mipmap-anydpi/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/macrobenchmark/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/macrobenchmark/src/main/res/mipmap-anydpi/ic_launcher_round.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/macrobenchmark/src/main/res/mipmap-anydpi/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/macrobenchmark/src/main/res/mipmap-hdpi/ic_launcher.webp b/macrobenchmark/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 0000000..c209e78 Binary files /dev/null and b/macrobenchmark/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/macrobenchmark/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/macrobenchmark/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 0000000..b2dfe3d Binary files /dev/null and b/macrobenchmark/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/macrobenchmark/src/main/res/mipmap-mdpi/ic_launcher.webp b/macrobenchmark/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 0000000..4f0f1d6 Binary files /dev/null and b/macrobenchmark/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/macrobenchmark/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/macrobenchmark/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 0000000..62b611d Binary files /dev/null and b/macrobenchmark/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/macrobenchmark/src/main/res/mipmap-xhdpi/ic_launcher.webp b/macrobenchmark/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 0000000..948a307 Binary files /dev/null and b/macrobenchmark/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/macrobenchmark/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/macrobenchmark/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..1b9a695 Binary files /dev/null and b/macrobenchmark/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/macrobenchmark/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/macrobenchmark/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 0000000..28d4b77 Binary files /dev/null and b/macrobenchmark/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/macrobenchmark/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/macrobenchmark/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9287f50 Binary files /dev/null and b/macrobenchmark/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/macrobenchmark/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/macrobenchmark/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/macrobenchmark/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/macrobenchmark/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/macrobenchmark/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 0000000..9126ae3 Binary files /dev/null and b/macrobenchmark/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/macrobenchmark/src/main/res/values/colors.xml b/macrobenchmark/src/main/res/values/colors.xml new file mode 100644 index 0000000..f8c6127 --- /dev/null +++ b/macrobenchmark/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/macrobenchmark/src/main/res/values/strings.xml b/macrobenchmark/src/main/res/values/strings.xml new file mode 100644 index 0000000..84d56e2 --- /dev/null +++ b/macrobenchmark/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + macrobenchmark + \ No newline at end of file diff --git a/macrobenchmark/src/main/res/values/themes.xml b/macrobenchmark/src/main/res/values/themes.xml new file mode 100644 index 0000000..47dc415 --- /dev/null +++ b/macrobenchmark/src/main/res/values/themes.xml @@ -0,0 +1,5 @@ + + + +