diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml
new file mode 100644
index 0000000..72077b1
--- /dev/null
+++ b/.github/workflows/benchmark.yml
@@ -0,0 +1,30 @@
+name: Cron Job
+
+on:
+ schedule:
+ - cron: '15 14 * * *'
+
+jobs:
+ benchmark:
+ runs-on: [ macOS ]
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ - name: Log Build Metadata
+ run: |
+ echo "Commit SHA: ${{ github.sha }}"
+ - name: Grant execute permission for gradlew
+ run: chmod +x gradlew
+ - name: Connected Devices
+ run: adb devices
+ - name: Benchmark
+ run: ./gradlew :benchmark:connectedCheck || true
+ - name: Connected Devices
+ run: adb devices
+ - name: Benchmark Report
+ run: |
+ for folder in benchmark/build/outputs/androidTest-results/connected/*/; do
+ echo "Device: $folder"
+ cat "$folder/testlog/test-results.log" || true
+ grep "android.studio.display.benchmark=UiTronBenchmark_startup" "$folder/testlog/test-results.log" -A 2 || true
+ done
diff --git a/app/build.gradle b/app/build.gradle
index a036504..eb15707 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -27,6 +27,11 @@ android {
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
+ benchmark {
+ initWith release
+ signingConfig signingConfigs.debug
+ matchingFallbacks = ['release']
+ }
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
@@ -68,4 +73,6 @@ dependencies {
androidTestImplementation "androidx.test.ext:junit:1.1.4"
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation "androidx.navigation:navigation-compose:$nav_version"
+ implementation 'androidx.profileinstaller:profileinstaller:1.3.1'
+
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 6b572d0..b119c17 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -16,6 +16,7 @@
android:supportsRtl="true"
android:theme="@style/Theme.UiTron"
tools:targetApi="31">
+
\ No newline at end of file
diff --git a/benchmark/src/main/java/com/navi/uitron/benchmark/UiTronBenchmark.kt b/benchmark/src/main/java/com/navi/uitron/benchmark/UiTronBenchmark.kt
new file mode 100644
index 0000000..0181935
--- /dev/null
+++ b/benchmark/src/main/java/com/navi/uitron/benchmark/UiTronBenchmark.kt
@@ -0,0 +1,33 @@
+package com.navi.uitron.benchmark
+
+import androidx.benchmark.macro.FrameTimingMetric
+import androidx.benchmark.macro.StartupMode
+import androidx.benchmark.macro.junit4.MacrobenchmarkRule
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.uiautomator.By
+import androidx.test.uiautomator.Until
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import java.util.concurrent.TimeUnit
+
+@RunWith(AndroidJUnit4::class)
+class UiTronBenchmark {
+ @get:Rule
+ val benchmarkRule = MacrobenchmarkRule()
+
+ @Test
+ fun startup() = benchmarkRule.measureRepeated(
+ packageName = "com.uitron.demo",
+ metrics = listOf(FrameTimingMetric()),
+ iterations = 3,
+ startupMode = StartupMode.COLD,
+ ) {
+ pressHome()
+ startActivityAndWait()
+ device.wait(
+ Until.hasObject(By.clazz("$packageName.MockActivity")),
+ TimeUnit.SECONDS.toMillis(1)
+ )
+ }
+}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 8cc0731..ffad80b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -8,4 +8,5 @@ plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
+ id 'com.android.test' version '7.3.1' apply false
}
diff --git a/settings.gradle b/settings.gradle
index 8d05981..a5a3266 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -31,3 +31,4 @@ dependencyResolutionManagement {
rootProject.name = "UiTron"
include ':app'
include ':navi-uitron'
+include ':benchmark'