secant-android-wallet/ui-benchmark-test/src/main/java/co/electriccoin/zcash/ui/benchmark/BasicStartupBenchmark.kt

40 lines
1.4 KiB
Kotlin
Raw Normal View History

[#599] Macrobenchmark test module * Temporary enable FTL test * Enable emulator.wft tests for ui-integration-test module on CI * Rebase onto main * Test Fladle configuration for ui-integration-test module * Fix Fladle for ui-integration-test module * Rename ui-integration-test module flade configuration * Disable again FTL action from PRs * Clear support for FTL from ui-integration-test module * Refactor the emulator.wtf support across our modules. * [#599] Macrobenchmark test module - Created new dedicated macrobenchmark test module - Updated related Architecture and Setup documentation - Connected to app module - New benchmark build type - Related run configuration above custom Gradle task - Basic startup benchmark test included * Benchmark build variant simplification * Run benchmarking simplification * Documentation update. * New property IS_SIGN_RELEASE_BUILD_WITH_DEBUG_KEY - It enables signing the release build with debug key configuration. Default value is false. - First, we check if we can sign it with release configs, otherwise with debug. - Documentation updated. * Benchmarking documentation update * Adds support for Android SDK 32 and 33 - Bumped benchmark library to the latest alpha version - Which results in a need of adding profile-installer library in target module (app) - Now we're able to run benchmarking on Android SDK level 29 and higher (i.e. latest levels included) - Updated related documentation * Enables benchmarking for emulators - I've decided to support emulator devices with our benchmark test module at the end. Documentation and code comments explain to a user that the results may not be the same as on a real physical device. But until we have it set up in CI, we can benefit from having it set up like this.
2022-10-27 03:51:24 -07:00
package co.electriccoin.zcash.ui.benchmark
import androidx.benchmark.macro.StartupMode
import androidx.benchmark.macro.StartupTimingMetric
import androidx.benchmark.macro.junit4.MacrobenchmarkRule
import org.junit.Rule
import org.junit.Test
/**
* This is an example startup benchmark. Its purpose is to provide basic startup measurements, and captured
* system traces for investigating the app's performance.
*
* It navigates to the device's home screen, and launches the default activity. Run this benchmark from Studio only
* against the release variant type and use one of the 'Benchmark' trailing build variants for this module.
* The 'Debug' trailing modules are also available, but they just provide compatibility with other debug modules.
*
* We ideally run this against a physical device with Android SDK level 29, at least, as profiling is provided by this
* version and later on.
*/
class BasicStartupBenchmark {
companion object {
private const val APP_TARGET_PACKAGE_NAME = "co.electriccoin.zcash"
}
@get:Rule
val benchmarkRule = MacrobenchmarkRule()
@Test
fun startup() = benchmarkRule.measureRepeated(
packageName = APP_TARGET_PACKAGE_NAME,
metrics = listOf(StartupTimingMetric()),
iterations = 5,
startupMode = StartupMode.COLD
) {
pressHome()
startActivityAndWait()
}
}