Upgrade to Pro — share decks privately, control downloads, hide ads and more …

jetpack_benchmark.pdf

 jetpack_benchmark.pdf

takako-fire

June 06, 2019
Tweet

More Decks by takako-fire

Other Decks in Programming

Transcript

  1. ಋೖํ๏ android { : defaultConfig { testInstrumentationRunner "androidx.benchmark.AndroidBenchmarkRunner" } :

    } dependencies { : // Testing dependencies androidTestImplementation "androidx.benchmark:benchmark:1.0.0-alpha01" } QSPKFDU@SPPUNPEVMF@EJSCVJMEHSBEMF
  2. ϕϯνϚʔΫΛଌఆ͢Δ @RunWith(AndroidJUnit4::class) class RecyclerViewBenchmark { @Test fun simpleScroll() { activityScenario.onActivity

    { benchmarkRule.measureRepeated { it.recyclerView.scrollBy( 0, it.recyclerView.getLastChild().height ) } } } } IUUQTHJUIVCDPNHPPHMFTBNQMFTBOESPJEQFSGPSNBODF
  3. ϕϯνϚʔΫΛଌఆ͢Δ inline fun BenchmarkRule.measureRepeated( crossinline block: BenchmarkRule.Scope.() -> Unit )

    { val localState = getState() val localScope = scope while (localState.keepRunningInline()) { block(localScope) } }
  4. ϕϯνϚʔΫΛଌఆ͢Δ Testing started at 02:04 ... 06/04 02:04:30: Launching 'RecyclerViewBenchmark'

    on asus ASUS_Z01MDA. Running tests $ adb shell am instrument -w -r -e debug false -e class 'com.example.benchmark.RecyclerViewBenchmark' com.example.benchmark.test/ androidx.benchmark.AndroidBenchmarkRunner Waiting for process to come online... Started running tests benchmark: 175,625 ns RecyclerViewBenchmark.simpleScroll Tests ran to completion.
  5. ؾΛ͚ͭΔ͜ͱ Started running tests benchmark: WARNING: Debuggable Benchmark benchmark: Benchmark

    is running with debuggable=true, which drastically reduces benchmark: runtime performance in order to support debugging features. Run benchmark: benchmarks with debuggable=false. Debuggable affects execution speed benchmark: in ways that mean benchmark improvements might not carry over to a benchmark: real user's experience (or even regress release performance). benchmark: benchmark: 196,119 ns DEBUGGABLE_RecyclerViewBenchmark.simpleScroll Tests ran to completion.