Skip to content

Commit

Permalink
Added Baseline Profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
mhss1 committed Oct 5, 2023
1 parent 2d1f3f7 commit b8dff52
Show file tree
Hide file tree
Showing 16 changed files with 11,481 additions and 7 deletions.
62 changes: 62 additions & 0 deletions .idea/androidTestResultsUserPreferences.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ android {
debug {
applicationIdSuffix ".debug"
}
benchmark {
initWith release
signingConfig signingConfigs.debug
matchingFallbacks = ['release']
debuggable false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
Expand Down Expand Up @@ -133,6 +139,9 @@ dependencies {

// Squircle shape
implementation "com.github.stoyan-vuchev:squircle-shape:1.0.3"

// Baseline profiler
implementation "androidx.profileinstaller:profileinstaller:1.3.1"
}

ksp {
Expand Down
11,202 changes: 11,202 additions & 0 deletions app/src/main/baseline-prof.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import androidx.compose.material3.Surface
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.core.net.toUri
import androidx.core.view.WindowCompat
import androidx.datastore.preferences.core.intPreferencesKey
Expand Down Expand Up @@ -45,6 +48,7 @@ class MainActivity : ComponentActivity() {

private val mainViewModel: MainViewModel by viewModels()

@OptIn(ExperimentalComposeUiApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
WindowCompat.setDecorFitsSystemWindows(window, false)
Expand Down Expand Up @@ -123,7 +127,9 @@ class MainActivity : ComponentActivity() {
}
}
Surface(
modifier = Modifier.fillMaxSize(),
modifier = Modifier.fillMaxSize().semantics {
testTagsAsResourceId = true
},
color = MaterialTheme.colorScheme.background
) {
NavHost(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.compositeOver
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -253,7 +254,8 @@ fun BaseChatSurface(
.consumeWindowInsets(paddingValues)
.padding(
horizontal = 4.dp
),
)
.testTag("messages-list"),
state = lazyListState,
horizontalAlignment = Alignment.CenterHorizontally,
reverseLayout = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.mo.sh.studyassistant.R
Expand Down Expand Up @@ -76,7 +77,8 @@ fun ChatBar(
.weight(1f)
.padding(top = 6.dp, bottom = 8.dp, start = 8.dp, end = 0.dp)
.heightIn(0.dp, 400.dp)
.border(1.5.dp, MaterialTheme.colorScheme.primary, RoundedCornerShape(32.dp)),
.border(1.5.dp, MaterialTheme.colorScheme.primary, RoundedCornerShape(32.dp))
.testTag("chat-text-field"),
colors = TextFieldDefaults.colors(
focusedContainerColor = MaterialTheme.colorScheme.surfaceVariant,
unfocusedContainerColor = MaterialTheme.colorScheme.surfaceVariant,
Expand Down Expand Up @@ -105,7 +107,8 @@ fun ChatBar(
)
IconButton(
onClick = { onSubmit() },
enabled = buttonEnabled
enabled = buttonEnabled,
modifier = Modifier.testTag("send-button")
) {
Icon(
painter = painterResource(R.drawable.ic_send),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -60,6 +61,7 @@ fun MainScreen(
}
.padding(4.dp)
.size(24.dp)
.testTag("settings-button")

)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.compositeOver
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.datastore.preferences.core.intPreferencesKey
Expand All @@ -49,7 +53,7 @@ import com.mo.sh.studyassistant.data.repository.DataStoreRepository.Companion.TH
import com.mo.sh.studyassistant.data.repository.DataStoreRepository.Companion.API_KEY
import dev.jeziellago.compose.markdowntext.MarkdownText

@OptIn(ExperimentalMaterial3Api::class)
@OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class)
@Composable
fun SettingsScreen(
viewModel: MainViewModel
Expand Down Expand Up @@ -175,7 +179,11 @@ fun SettingsScreen(
},
modifier = Modifier
.fillMaxWidth()
.padding(8.dp),
.padding(8.dp)
.semantics {
testTagsAsResourceId = true
}
.testTag("api-key-text-field"),
shape = RoundedCornerShape(8.dp)
)
Spacer(Modifier.height(8.dp))
Expand Down
1 change: 1 addition & 0 deletions benchmark/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
1 change: 1 addition & 0 deletions benchmark/benchmark-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-dontobfuscate
72 changes: 72 additions & 0 deletions benchmark/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import com.android.build.api.dsl.ManagedVirtualDevice

plugins {
id 'com.android.test'
id 'org.jetbrains.kotlin.android'
}

android {
namespace 'com.mhss.app.benchmark'
compileSdk 33

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

kotlinOptions {
jvmTarget = "1.8"
}

defaultConfig {
minSdk 26
targetSdk 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments["androidx.benchmark.suppressErrors"] = "NOT-PROFILEABLE"

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
buildConfigField "String", "TEST_API_KEY", "\"${properties.getProperty('TEST_API_KEY')}\""
}

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"]
proguardFiles 'benchmark-rules.pro'
}
}

buildFeatures {
buildConfig true
}

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

testOptions.managedDevices.devices {
pixel6Api31(ManagedVirtualDevice) {
device 'Pixel 6'
apiLevel 31
systemImageSource 'aosp'
}
}
}

dependencies {
implementation 'androidx.test.ext:junit:1.1.5'
implementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'androidx.test.uiautomator:uiautomator:2.2.0'
implementation 'androidx.benchmark:benchmark-macro-junit4:1.1.1'
}

androidComponents {
beforeVariants(selector().all()) {
enable = buildType == "benchmark"
}
}
1 change: 1 addition & 0 deletions benchmark/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest />
Loading

0 comments on commit b8dff52

Please sign in to comment.