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

Add benchmarks for TypicalUserJourney, Enable baselineprofile generator, and some metrics #601

Merged
merged 32 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ab7a05d
Add initial StartupBenchmarks
MV-GH Jun 11, 2023
68e2c48
Add startup profile gen + dex support for it
MV-GH Jun 11, 2023
9ae00cf
Add current progress
MV-GH Jun 12, 2023
0f5a4b6
Fix benchmarks and TEMP remove DEX layout optimizations
MV-GH Jun 13, 2023
c481630
Update profiles using new UserJourney
MV-GH Jun 13, 2023
8aa699a
Add baseline gen config and general benchmark changes
MV-GH Jun 13, 2023
5789f99
Update build.gradle fix warning DEBUGGABLE
MV-GH Jun 13, 2023
38009dd
Enable compose compiler metrics
MV-GH Jun 13, 2023
669fd32
Merge branch 'main' into benchmarks
MV-GH Jun 13, 2023
f610c79
Merge branch 'main' into benchmarks
MV-GH Jun 13, 2023
dbefd03
Merge branch 'main' into benchmarks
MV-GH Jun 13, 2023
8885b9e
Remove leftover comment
MV-GH Jun 13, 2023
3218152
Merge branch 'main' into benchmarks
MV-GH Jun 14, 2023
ee1e7e4
Fix merge conflicts
MV-GH Jun 14, 2023
6a5c1a4
Merge branch 'main' into benchmarks
MV-GH Jun 14, 2023
2f4a216
Fix formatting
MV-GH Jun 14, 2023
7212624
Merge branch 'main' into benchmarks
MV-GH Jun 15, 2023
d00a629
Merge branch 'main' into benchmarks
MV-GH Jun 15, 2023
0cfc1b8
Merge branch 'main' into benchmarks
dessalines Jun 19, 2023
0196254
Merge branch 'main' into benchmarks
MV-GH Jun 19, 2023
85e0d93
Fix merge issues
MV-GH Jun 19, 2023
d0149fe
Fix benchmarks
MV-GH Jun 19, 2023
fc4d566
Change baseline profile generator config
MV-GH Jun 19, 2023
e3a5884
Merge branch 'main' into benchmarks
MV-GH Jun 19, 2023
fa2e445
Update util
MV-GH Jun 19, 2023
dc2c79e
Fix benchmarks and update generated profiles
MV-GH Jun 19, 2023
49e4c9f
Fix accidental changes
MV-GH Jun 19, 2023
d471f68
Merge branch 'main' into benchmarks
MV-GH Jun 19, 2023
b4a712f
Merge branch 'main' into benchmarks
MV-GH Jun 19, 2023
8c31a24
Merge branch 'main' into benchmarks
MV-GH Jun 19, 2023
7f3702f
Merge branch 'main' into benchmarks
dessalines Jun 20, 2023
9d51224
Merge branch 'main' into benchmarks
MV-GH Jun 20, 2023
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
32 changes: 32 additions & 0 deletions .run/Generate Baseline Profile (show display).run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!--
This task runs the base profile generators with the display on
instead of headless but you will have to manually copy over the generated profiles
With something like this
adb -e pull "/storage/emulated/0/Android/media/com.jerboa.benchmarks/BaselineProfileGenerator_startup-baseline-prof-2022-03-08-13-37-55.txt
-->
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Generate Baseline Profile (show display)" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="-Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value=":benchmarks:pixel6Api31BenchmarkAndroidTest" />
<option value="--rerun" />
<option value="--enable-display" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<ForceTestExec>false</ForceTestExec>
<method v="2" />
</configuration>
</component>
24 changes: 24 additions & 0 deletions .run/Generate Baseline Profile.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Generate Baseline Profile" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="-Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value=":app:generateReleaseBaselineProfile" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<ForceTestExec>false</ForceTestExec>
<method v="2" />
</configuration>
</component>
6 changes: 6 additions & 0 deletions app/benchmark-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Proguard rules for the `benchmark` build type.
#
# Obsfuscation must be disabled for the build variant that generates Baseline Profile, otherwise
# wrong symbols would be generated. The generated Baseline Profile will be properly applied when generated
# without obfuscation and your app is being obfuscated.
-dontobfuscate
14 changes: 13 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.devtools.ksp'
id 'androidx.baselineprofile'
}

android {
Expand Down Expand Up @@ -46,11 +47,19 @@ android {
signingConfig signingConfigs.release
}
}

debug {
applicationIdSuffix '.debug'
versionNameSuffix ' (DEBUG)'
}

generateProfiles { // use this variant to generate the profiles
minifyEnabled false // The startup profiles needs minification off
shrinkResources false
debuggable false
signingConfig signingConfigs.debug
proguardFiles 'benchmark-rules.pro' // The baseline profile generator needs obfuscation off
applicationIdSuffix = ".benchmark"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
Expand Down Expand Up @@ -134,4 +143,7 @@ dependencies {
debugImplementation 'androidx.compose.ui:ui-test-manifest:1.4.3'
implementation "net.engawapg.lib:zoomable:1.4.3"
implementation 'androidx.browser:browser:1.5.0'

implementation 'androidx.profileinstaller:profileinstaller:1.3.1'
baselineProfile project(path: ':benchmarks')
}
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
android:supportsRtl="true"
android:theme="@style/Theme.Jerboa"
tools:targetApi="33">
<profileable android:shell="true"/>


<activity
android:name=".MainActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -65,7 +66,7 @@ fun SimpleTopAppBar(
)
},
navigationIcon = {
IconButton(onClick = { navController.popBackStack() }) {
IconButton(onClick = { navController.popBackStack() }, modifier = Modifier.testTag("jerboa:back")) {
Icon(
Icons.Outlined.ArrowBack,
contentDescription = stringResource(R.string.topAppBar_back),
Expand Down Expand Up @@ -585,5 +586,5 @@ fun Modifier.simpleVerticalScrollbar(
fun LoadingBar(
padding: PaddingValues = PaddingValues(0.dp),
) {
LinearProgressIndicator(modifier = Modifier.fillMaxWidth().padding(padding))
LinearProgressIndicator(modifier = Modifier.fillMaxWidth().padding(padding).testTag("jerboa:loading"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ import androidx.compose.runtime.livedata.observeAsState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.tooling.preview.Preview
import com.jerboa.PostViewMode
import com.jerboa.R
Expand Down Expand Up @@ -313,6 +317,7 @@ fun ListingTypeOptionsDialogPreview() {
)
}

@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun ShowChangelog(appSettingsViewModel: AppSettingsViewModel) {
val changelogViewed = appSettingsViewModel.appSettings.observeAsState().value?.viewedChangelog
Expand All @@ -325,7 +330,6 @@ fun ShowChangelog(appSettingsViewModel: AppSettingsViewModel) {

if (whatsChangedDialogOpen) {
val scrollState = rememberScrollState()

val markdown by appSettingsViewModel.changelog.collectAsState()
LaunchedEffect(appSettingsViewModel) {
appSettingsViewModel.updateChangelog()
Expand All @@ -350,7 +354,7 @@ fun ShowChangelog(appSettingsViewModel: AppSettingsViewModel) {
whatsChangedDialogOpen = false
appSettingsViewModel.markChangelogViewed()
},
modifier = Modifier.fillMaxWidth(),
modifier = Modifier.fillMaxWidth().testTag("jerboa:changelogbtn"),
) {
Text(stringResource(R.string.dialogs_done))
}
Expand All @@ -359,6 +363,7 @@ fun ShowChangelog(appSettingsViewModel: AppSettingsViewModel) {
whatsChangedDialogOpen = false
appSettingsViewModel.markChangelogViewed()
},
modifier = Modifier.semantics { testTagsAsResourceId = true },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.jerboa.ui.theme.LARGE_PADDING
@Composable
fun IconAndTextDrawerItem(
text: String,
modifier: Modifier = Modifier,
icon: ImageVector? = null,
iconBadgeCount: Int? = null,
onClick: () -> Unit,
Expand All @@ -39,7 +40,7 @@ fun IconAndTextDrawerItem(
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
modifier = modifier
.fillMaxWidth()
.clickable(onClick = onClick)
.background(
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/com/jerboa/ui/components/home/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
Expand Down Expand Up @@ -576,7 +580,7 @@ fun HomeHeader(
contentDescription = stringResource(R.string.selectSort),
)
}
IconButton(onClick = {
IconButton(modifier = Modifier.testTag("jerboa:options"), onClick = {
showMoreOptions = !showMoreOptions
}) {
Icon(
Expand Down Expand Up @@ -609,6 +613,7 @@ fun HomeHeaderPreview() {
)
}

@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun HomeMoreDialog(
onDismissRequest: () -> Unit,
Expand All @@ -618,6 +623,7 @@ fun HomeMoreDialog(
) {
AlertDialog(
onDismissRequest = onDismissRequest,
modifier = Modifier.semantics { testTagsAsResourceId = true },
text = {
Column {
IconAndTextDrawerItem(
Expand All @@ -627,6 +633,7 @@ fun HomeMoreDialog(
onDismissRequest()
onClickRefresh()
},
modifier = Modifier.testTag("jerboa:refresh"),
)
IconAndTextDrawerItem(
text = stringResource(R.string.home_post_view_mode),
Expand Down
14 changes: 12 additions & 2 deletions app/src/main/java/com/jerboa/ui/components/home/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.jerboa.ui.components.home

import android.content.Context
import android.util.Log
import androidx.activity.compose.ReportDrawnWhen
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
Expand Down Expand Up @@ -32,10 +33,13 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.navigation.NavController
import com.jerboa.R
import com.jerboa.VoteType
Expand Down Expand Up @@ -64,7 +68,7 @@ import com.jerboa.ui.components.post.PostListings
import com.jerboa.ui.components.post.edit.PostEditViewModel
import kotlinx.coroutines.CoroutineScope

@OptIn(ExperimentalMaterial3Api::class)
@OptIn(ExperimentalMaterial3Api::class, ExperimentalComposeUiApi::class)
@Composable
fun HomeActivity(
navController: NavController,
Expand Down Expand Up @@ -104,7 +108,8 @@ fun HomeActivity(
},
content = {
Scaffold(
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection)
.semantics { testTagsAsResourceId = true },
snackbarHost = { SnackbarHost(snackbarHostState) },
topBar = {
MainTopBar(
Expand Down Expand Up @@ -180,6 +185,7 @@ fun HomeActivity(
},
)
},
modifier = Modifier.semantics { testTagsAsResourceId = true },
)
}

Expand Down Expand Up @@ -213,6 +219,10 @@ fun MainPostListingsContent(

val loading = homeViewModel.postsRes == ApiState.Loading || homeViewModel.fetchingMore

ReportDrawnWhen {
!loading
}

val pullRefreshState = rememberPullRefreshState(
refreshing = loading,
onRefresh = {
Expand Down
22 changes: 18 additions & 4 deletions app/src/main/java/com/jerboa/ui/components/post/PostActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ 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.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
import androidx.navigation.NavController
import com.jerboa.PostViewMode
import com.jerboa.R
Expand Down Expand Up @@ -67,6 +71,7 @@ import com.jerboa.ui.components.common.simpleVerticalScrollbar
import com.jerboa.ui.components.home.SiteViewModel
import com.jerboa.ui.components.post.edit.PostEditViewModel

@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun CommentsHeaderTitle(
selectedSortType: CommentSortType,
Expand All @@ -85,7 +90,11 @@ fun CommentsHeaderTitle(
}
}

@OptIn(ExperimentalMaterialApi::class, ExperimentalMaterial3Api::class)
@OptIn(
ExperimentalMaterialApi::class,
ExperimentalMaterial3Api::class,
ExperimentalComposeUiApi::class,
)
@Composable
fun PostActivity(
postViewModel: PostViewModel,
Expand Down Expand Up @@ -136,7 +145,8 @@ fun PostActivity(
}

Scaffold(
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection)
.semantics { testTagsAsResourceId = true },
topBar = {
Column {
TopAppBar(
Expand All @@ -146,7 +156,10 @@ fun PostActivity(
)
},
navigationIcon = {
IconButton(onClick = { navController.popBackStack() }) {
IconButton(
modifier = Modifier.testTag("jerboa:back"),
onClick = { navController.popBackStack() },
) {
Icon(
Icons.Outlined.ArrowBack,
contentDescription = stringResource(R.string.topAppBar_back),
Expand Down Expand Up @@ -185,7 +198,8 @@ fun PostActivity(
state = listState,
modifier = Modifier
.padding(padding)
.simpleVerticalScrollbar(listState),
.simpleVerticalScrollbar(listState)
.testTag("jerboa:comments"),
) {
item(key = "${postView.post.id}_listing") {
PostListing(
Expand Down
Loading