<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ben Weiss on Medium]]></title>
        <description><![CDATA[Stories by Ben Weiss on Medium]]></description>
        <link>https://medium.com/@keyboardsurfer?source=rss-65fe4f480b1c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1U4KLr4rAKxPq0CrpL3vrQ.jpeg</url>
            <title>Stories by Ben Weiss on Medium</title>
            <link>https://medium.com/@keyboardsurfer?source=rss-65fe4f480b1c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 08:24:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@keyboardsurfer/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What’s new in Jetpack Benchmark 1.2.0]]></title>
            <link>https://medium.com/androiddevelopers/whats-new-in-jetpack-benchmark-1-2-0-82da5092fc43?source=rss-65fe4f480b1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/82da5092fc43</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[benchmarking]]></category>
            <category><![CDATA[baseline-profiles]]></category>
            <dc:creator><![CDATA[Ben Weiss]]></dc:creator>
            <pubDate>Thu, 19 Oct 2023 16:02:41 GMT</pubDate>
            <atom:updated>2023-10-20T09:46:23.728Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tebpw326SZ5SzhkXGPYJrA.png" /><figcaption>Illustration by Claudia Sanchez</figcaption></figure><h4>This big release brings stable Baseline Profiles, new benchmarking modes, full tracing and more.</h4><p>The <a href="https://developer.android.com/topic/performance/benchmarking/benchmarking-overview">Jetpack Benchmark library</a> provides a set of tools to inspect and improve application performance in a controlled environment.</p><p>These lab tests can inspect entire end to end user flows using <a href="https://developer.android.com/topic/performance/benchmarking/macrobenchmark-overview">Macrobenchmark</a> or implementation details in a loop with <a href="https://developer.android.com/topic/performance/benchmarking/microbenchmark-overview">Microbenchmark</a>.</p><p>Macrobenchmark also can be used to generate <a href="https://developer.android.com/topic/performance/baselineprofiles/overview">baseline profiles</a> and now Startup Profiles. Both help to improve application performance.</p><p>All these features are provided by the androidx.benchmark library group. Despite the minor version increment from 1.1.1 to 1.2.0, a lot of new features have been added. Let’s dive into what’s new in Jetpack Benchmark 1.2.0.</p><h3>New in baseline profiles</h3><p><a href="https://developer.android.com/topic/performance/baselineprofiles/overview">Baseline profiles</a> <strong>improve overall code execution speed</strong> of included paths by about 30% by avoiding interpretation and the cost of class initialization by ahead of time compiling.</p><p>These profiles have been around for a while and are already used by many apps and games on the Google Play Store. <a href="https://developer.android.com/topic/performance/baselineprofiles/create-baselineprofile-library">Libraries can also contribute</a> baseline profiles and improve app performance seamlessly. And with the new Gradle plugin, automated baseline profile generation is easier than ever.</p><h4>✨ Baseline profile API is now stable ✨</h4><p>With the Benchmark 1.2.0 release baseline profiles are no longer experimental.</p><p>When baseline profiles were introduced as an experimental feature in Benchmark 1.1.0, it shipped with the collectBaselineProfile API. It was replaced by the simpler <a href="https://developer.android.com/reference/androidx/benchmark/macro/junit4/BaselineProfileRule#collect(kotlin.String,kotlin.Int,kotlin.Int,kotlin.String,kotlin.Boolean,kotlin.Boolean,kotlin.Function1,kotlin.Function1)">collect</a>.<strong> </strong>You now can generate stable baseline profiles and use <a href="https://developer.android.com/training/testing/other-components/ui-automator">UiAutomator</a> to capture user journeys as part of the profile.</p><p>To see the API in action, check out the <a href="https://developer.android.com/topic/performance/baselineprofiles/overview">documentation</a> and <a href="http://github.com/android/performance-samples">samples</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/60f2df901ae499ee583a8e6870a8eb59/href">https://medium.com/media/60f2df901ae499ee583a8e6870a8eb59/href</a></iframe><p>Above code collects a baseline profile for app startup and a user journey where UiAutomator is used to find the “For You” text, click it and then scroll a column down and up.</p><h4>Set up baseline profile modules using Android Studio Canary</h4><p>We’re working on improving the set up experience for baseline profiles. This new experience is available in the Android Studio Iguana Canary builds.</p><p>The Android Studio baseline profile Generator module template automates the creation of a new module to generate and <a href="https://developer.android.com/topic/performance/baselineprofiles/measure-baselineprofile">benchmark</a> baseline profiles. Running the template generates most of the typical build configuration, baseline profile generation, and verification code. The template creates code to generate and benchmark baseline profiles. This helps to improve and measure app startup times.</p><p>Create a new module and select “Baseline Profile Generator”, go through the dialog and click finish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/0*Xno_KGK88ovARJ1d" /></figure><p>Now you can generate baseline profiles directly from the Run dialog in Android Studio</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/0*jC3hvRt-QbnH0dln" /></figure><h4>Automate baseline profile generation with a Gradle plugin</h4><p>A high priority feature request from developers implementing baseline profiles was to help them with automating the process.</p><p>When using AGP 8.0 or newer you can now use the <a href="https://developer.android.com/topic/performance/baselineprofiles/create-baselineprofile#baseline-profile-gradle-plugin">Baseline Profile Gradle plugin</a>. This plugin lets you fully control baseline profile creation. It seamlessly integrates profile generation in the Gradle build pipeline. You can control when the profile will update and make sure it’s always fresh for a new release.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8a909e7508cd5429999d41f533f85ad/href">https://medium.com/media/a8a909e7508cd5429999d41f533f85ad/href</a></iframe><p>To use the Gradle plugin, apply it to your app and baseline profile modules. You can do this manually, <a href="https://developer.android.com/topic/performance/baselineprofiles/create-baselineprofile#baseline-profile-gradle-plugin">following the guide</a> or with Android Studio Iguana’s new module template for baseline profiles. The plugin offers <a href="https://developer.android.com/topic/performance/baselineprofiles/configure-baselineprofiles">wide configuration options</a> for high flexibility. You can use Gradle managed devices for ease of running on a CI system. baseline-prof.txt source files no longer have to be part of your app’s source set when using the Gradle plugin. They can be considered reproducibly generated code.</p><h4>Simplified profile filtering empower complex applications and library developers</h4><p>Large code bases or libraries require filter mechanisms to only include specific classes in a baseline profile. The Gradle plugin <a href="https://developer.android.com/topic/performance/baselineprofiles/configure-baselineprofiles#filter-profile-rules">provides just that</a>. The new filter block enables including or excluding code via regular expressions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/92cab7b6da572ac08260592c11a58e0e/href">https://medium.com/media/92cab7b6da572ac08260592c11a58e0e/href</a></iframe><h3>New in Macrobenchmark</h3><h4>Arguments to improve benchmarks</h4><h4>New profiling modes</h4><p>Method tracing and stack sampling modes are now available with Macrobenchmark.</p><p>With these profile modes you can get detailed information on specific areas of the code that’s being executed. To enable it, use the androidx.benchmark.profiling.mode argument with the StackSampling or MethodTracing parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WmP3fBnQU76xt5RJ" /></figure><p>With MethodTracing you can see exactly which methods are being called while a code block executes. This can help to identify whether the app is doing what you expect it to do at a glance.</p><p>StackSampling highlights where the benchmark spends time across all call stacks. With this you can see where the app spends most of the time during a run.</p><blockquote>⚠️</blockquote><blockquote><strong>Note:</strong> These two modes are known to skew performance metrics. You can rely on them to see what is going on during runtime but do take frame timing or startup results with a grain of salt when method tracing or stack sampling is enabled.</blockquote><blockquote>⚠️</blockquote><h4>Quicker validation with dry runs</h4><p>The dryRunMode.enable instrumentation argument enables quicker validation. This can be useful for presubmit environments or during development of a benchmark and brings the flag from Microbenchmark to Macrobenchmark.</p><h4>Use Perfetto Sdk Tracing for higher resolution metrics</h4><p>To get even more details when benchmarking you can trace app behavior with Perfetto Sdk Tracing. While this loads a library during app runtime and slows down StartupMode.COLD benchmarks, it does give you a more detailed and full picture of what’s happening during a benchmark. This can be very useful when you suspect areas of improvement not being surfaced by regular tracing.</p><p>To enable Perfetto Sdk tracing, add these dependencies to your benchmark module,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/60d02f48e16360969f0a20a917e0218d/href">https://medium.com/media/60d02f48e16360969f0a20a917e0218d/href</a></iframe><p>and run the benchmarks with the perfettoSdkTracing.enable instrumentation argument.</p><h3>More insight with new experimental metrics</h3><p>New metrics in the Macrobenchmark library provide you with more insights into data and further empower automated monitoring.</p><h4>Post process anything with PerfettoTraceProcessor</h4><p>The <a href="https://developer.android.com/reference/androidx/benchmark/perfetto/PerfettoTraceProcessor">PerfettoTraceProcessor</a> API brings every detail from a benchmark result into a single API. It’s highly flexible and enables synchronous and async trace sections, kernel-level scheduling timing, binder events and anything else that’s captured in a Perfetto trace.</p><p>Now you can use the same trace querying API in macrobenchmark. This is especially useful to create your own fully custom TraceMetric.</p><h4>Surface more details with TraceSectionMetric and TraceMetric</h4><p>These trace specific APIs enable quick processing of specific sections and traces of an app.</p><p>The TraceSectionMetric enables capturing custom trace sections in an app. For example, you can use the <a href="https://developer.android.com/reference/androidx/benchmark/macro/TraceSectionMetric">TraceSectionMetric</a> to capture how long specific parts during activity startup took. This example shows how you can collect the duration of the onStart and onResume methods. Additionally, below sample aggregates the amount of time it took to render frames by capturing the doFrame trace using Mode.Sum.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb48be69acb039cf8d060b30f0565cc5/href">https://medium.com/media/fb48be69acb039cf8d060b30f0565cc5/href</a></iframe><p>These metrics are all surfaced as part of the benchmark results and can help inform decisions on where to optimize as well as monitor for potential performance regressions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iVg6bRr6nv5lkVCj" /><figcaption>Metrics result from above code snippet</figcaption></figure><p>Macrobenchmark now also ships with the new <a href="https://developer.android.com/reference/androidx/benchmark/macro/TraceMetric">TraceMetric</a>. This API enables you to create your own complex metrics from macrobenchmark data as it enables you to run arbitrary queries against Perfetto traces. You can take any data that is captured in the Perfetto trace during a benchmark run and turn it into a metric. You can learn more about how to use the available data <a href="https://perfetto.dev/docs/analysis/trace-processor">in the Perfetto documentation</a>.</p><h4>Understand power consumption with PowerMetric</h4><p><a href="https://developer.android.com/reference/androidx/benchmark/macro/PowerMetric">PowerMetric</a> captures the change of power, energy or battery charge metrics over time for specified duration.</p><p>This metric provides details about <a href="https://developer.android.com/reference/androidx/benchmark/macro/PowerMetric#Battery()">Battery</a>, <a href="https://developer.android.com/reference/androidx/benchmark/macro/PowerMetric#Energy(kotlin.collections.Map)">Energy</a>, and <a href="https://developer.android.com/reference/androidx/benchmark/macro/PowerMetric#Power(kotlin.collections.Map)">Power</a> when running on a device with power rails such as Pixel 6 or newer.</p><p>With this information you can verify how resource hungry a specific part of an application is or how different polling intervals of APIs such as location services affect battery levels. And you can even see how animations or dark mode affect power consumption and tweak how your application can save power on different display types such as AMOLED or OLED.</p><h3>New in Microbenchmark</h3><p>Profiling a microbenchmark is important, so we’ve made the profiling iteration loop faster, and more configurable. Profiling now runs as a separate phase in microbenchmarks, after all metrics are collected, so you can see both profiling results and measurements, or run profiling continuously in CI.</p><p>We’ve also added an experimental API to let you select a profiler in the code, while you’re iterating on the microbenchmark. This experimental API lets you configure tracing, like enabling the custom `trace()` sections that are off by default in micro to avoid interference with shouldEnableAppTagTracing.</p><h4>Configure Microbenchmark behavior from within</h4><p>With <a href="https://developer.android.com/reference/kotlin/androidx/benchmark/MicrobenchmarkConfig">MicrobenchmarkConfig</a> you can configure the way to capture a benchmark without having to rely on instrumentation arguments.</p><p>This enables configuring profiling or trace behavior, meaning you can enable trace app tags or perfetto sdk tracing per benchmark rule.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a68f8c4975219c260974bdb1490392c/href">https://medium.com/media/9a68f8c4975219c260974bdb1490392c/href</a></iframe><p>With these enabled you see a new “Trace” and “Stack Sampling Trace” link in benchmark results, which can be inspected using Android Studio Profilers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_CpA2mCgTnket7VK" /></figure><p>To enable tracing, you need to add dependencies on both, the perfetto tracing and perfetto binary libraries, to your microbenchmark tests. Failure to do this will result in this runtime exception.</p><pre>java.lang.RuntimeException:<br>Issue while enabling Perfetto SDK tracing in com.example.benchmark.test:<br><br>Error:<br>Unable to locate libtracing_perfetto.so required to enable Perfetto SDK.<br>Tried inside /data/app/com.example.benchmark.test/base.apk.</pre><h4>Control benchmark state without JUnit</h4><p><a href="https://developer.android.com/reference/kotlin/androidx/benchmark/BenchmarkState">BenchmarkState</a> allows querying the state of a benchmark without relying on JUnit APIs. With this you can instantiate BenchmarkState, which is particularly useful when you’re not using JUnit4.</p><h4>Capture and customize Perfetto traces</h4><p>The <a href="https://developer.android.com/reference/androidx/benchmark/junit4/PerfettoTraceRule">PerfettoTraceRule</a> helps you analyze test performance in detail. When using <a href="https://developer.android.com/reference/androidx/benchmark/perfetto/PerfettoTrace#record(kotlin.String,androidx.benchmark.perfetto.PerfettoConfig,kotlin.String,kotlin.String,kotlin.Function1,kotlin.Function0)">PerfettoTrace.record</a> you can write trace-based unit tests or create your own test infrastructure on top of Perfetto traces.</p><h3>Performance optimizations and bugfixes</h3><p>Next to all these new features, bugs were fixed and performance of the library group improved. To see everything that changed in between version 1.1.1 and 1.2.0, <a href="https://developer.android.com/jetpack/androidx/releases/benchmark">read the release notes</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82da5092fc43" width="1" height="1" alt=""><hr><p><a href="https://medium.com/androiddevelopers/whats-new-in-jetpack-benchmark-1-2-0-82da5092fc43">What’s new in Jetpack Benchmark 1.2.0</a> was originally published in <a href="https://medium.com/androiddevelopers">Android Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Turo reduced its app startup time by 77% using Android Developer tools and best practices]]></title>
            <link>https://medium.com/androiddevelopers/turo-reduced-its-app-startup-time-by-77-using-android-developer-tools-and-best-practices-bcf82f596bcf?source=rss-65fe4f480b1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcf82f596bcf</guid>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[case-study]]></category>
            <dc:creator><![CDATA[Ben Weiss]]></dc:creator>
            <pubDate>Fri, 12 May 2023 18:37:45 GMT</pubDate>
            <atom:updated>2023-05-12T18:37:45.711Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QxIXklsXEPl5S01e0qdOsg.gif" /></figure><p><a href="https://turo.com/">Turo</a> is the world’s largest car sharing marketplace where guests can book any car they want, and wherever they want it, from a vibrant community of trusted hosts.</p><p>Developers at Turo recently invested heavily in improving the startup performance of its Android application. <a href="https://developer.android.com/topic/performance/vitals/launch-time">Startup time</a> is the first impression users have of an app, and slower load times can negatively impact user retention and engagement. The team wanted to give users a faster, more streamlined experience every time they launched the app. And using Android’s best tools, resources, and practices, they were able to cut the app’s startup time by 77%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*swQbX1RF_PBoIxR0rVOEkA.png" /></figure><h3><strong>Setting the stage with the App Startup library</strong></h3><p>App initialization includes an application’s entire startup process and all the code it runs before rendering its first UI frame. For Turo, this meant users had to wait for the app to run its initial startup, synchronous network requests, and a custom splash animation — all before they were ever shown the app’s home screen.</p><p>Turo’s developers knew that to improve the application’s loading times, they would need to condense and remove many of these cumbersome startup events. To help pare down these events, Turo engineers used Android’s <a href="https://developer.android.com/topic/libraries/app-startup">App Startup library</a>.</p><p>The App Startup library gave Turo’s developers a simple, streamlined way to initialize multiple components during the application’s launch. It also enabled them to select which components to initialize and in what order, allowing them to significantly improve load times. Having the App Startup library in place set the foundation for the rest of Turo’s startup optimization.</p><h3><strong>Deferring network requests and cutting the splash screen</strong></h3><p>Prior to optimization, the app performed multiple network requests sequentially and then displayed a custom, one-second <a href="https://developer.android.com/develop/ui/views/launch/splash-screen">splash animation</a> before users could access the app’s home screen. This resulted in a slow startup process, especially if a user had poor network connectivity.</p><p>Removing the splash animation was an easy way for Turo developers to improve perceived loading time. And by making network requests parallel and asynchronous, users could access the home screen much faster. “Initially, we used a dedicated SplashActivity to run all the startup work before routing the app to the HomeActivity. However, the latest guidelines advise against this approach. Therefore, we eliminated the redundant SplashActivity and transferred all the startup logic to our root activity by leveraging the Splash Screen API,” said Pavlo Stavytskyi, a senior staff software engineer at Turo.</p><p>At the same time, the app was also performing a number of other startup network requests to tailor the experience to individual users, resulting in inconsistent user experiences.“If the app is used by a guest, some network requests help decide which screen should be shown after the splash screen,” said Pavlo. “By default, it’s the home screen. However, there are special cases where the user could be redirected either straight to an active vehicle reservation or to a feedback screen.”</p><p>The team didn’t want to slow down every app startup by checking for these niche scenarios. Instead, Turo now always opens the home screen by default while making network requests asynchronously. If a redirect is required, the appropriate screen is displayed on top of the home screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gi0lz7S5eL1oc9-aup1RVQ.gif" /></figure><h3><strong>Applying Baseline Profiles</strong></h3><p>The Turo team also applied <a href="https://developer.android.com/topic/performance/baselineprofiles/overview">Baseline Profiles</a> to improve the application’s performance. Baseline profiles help pre-compile startup code paths ahead of time, boosting Turo’s app startup time by another 15% according to Macrobenchmark tests. “After we removed all the synchronous network requests, our startup duration became more deterministic, and it made more sense to apply Baseline Profiles,” said Pavlo.</p><p>Performance improvements can lead to improved user retention, increased transactions, and better ratings. Baseline Profiles are a quick and reliable way to move the needle by a large amount.</p><h3><strong>Prioritizing startup performance</strong></h3><p>There are many factors that can impact an app’s startup time. It’s up to developers to identify where, when, and how they can improve their app to ensure it’s optimized for the best user experience.</p><p>“It’s important to start the improvement with tasks that require the least effort and produce the greatest results,” said Pavlo. “In many cases, engineering faces a conflict between allocating time and resources either on product work or performance optimization. However, treating performance as a stand-alone product feature is inevitable for its success.”</p><h3><strong>Optimize your app today</strong></h3><p>Improve your app’s startup time with <a href="https://developer.android.com/topic/performance/appstartup/best-practices">Android’s best practices for app optimization</a>, <a href="https://developer.android.com/topic/libraries/app-startup">Android’s App Startup</a>, and <a href="https://developer.android.com/topic/performance/baselineprofiles/overview">Baseline Profiles</a>.</p><blockquote>You also can read the full story of how <a href="https://morfly.medium.com/650cc113c3dc">Turo improved its app’s startup efficiency</a> using Android’s developer tools and best practices.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcf82f596bcf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/androiddevelopers/turo-reduced-its-app-startup-time-by-77-using-android-developer-tools-and-best-practices-bcf82f596bcf">Turo reduced its app startup time by 77% using Android Developer tools and best practices</a> was originally published in <a href="https://medium.com/androiddevelopers">Android Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s new in Android Performance — Google I/O 2023 edition]]></title>
            <link>https://medium.com/androiddevelopers/whats-new-in-android-performance-google-i-o-2023-edition-21a1832c9fa3?source=rss-65fe4f480b1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/21a1832c9fa3</guid>
            <category><![CDATA[android-development]]></category>
            <category><![CDATA[google-io-2023]]></category>
            <category><![CDATA[android-performance]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Ben Weiss]]></dc:creator>
            <pubDate>Wed, 10 May 2023 16:15:00 GMT</pubDate>
            <atom:updated>2023-05-15T11:49:48.349Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jO0F7-j-sbk3PxXokxW21w.png" /></figure><h3>What’s new in Android Performance — Google I/O 2023 edition</h3><p>Over the past years we have worked to make working with performance more approachable and rewarding. In this article we share the <strong>latest developments</strong> in that area. We’ll cover <strong>Baseline Profiles</strong>, <strong>tooling improvements</strong> within <strong>Android Studio</strong>, <strong>libraries</strong> and how we made the technology work better for you behind the scenes. We’re also very excited to share <strong>new experimental technology</strong>, working on top of Baseline Profiles, to provide you with even bigger startup performance improvements. Read on for a full tour of what’s new in Android Performance during Google I/O 2023, or jump directly to the end for actionable steps in your performance journey.</p><h3>Updates on Baseline Profiles</h3><p>Baseline Profiles improve code execution speed by about 30 %, for both app startup and runtime by avoiding just-in-time (JIT) compilation. We built several tools to help you streamline Baseline Profile creation and maintenance, including a new <strong>Android Studio Template</strong> and the <strong>Baseline Profile Gradle plugin</strong>. You can get started with both today, using Android Studio Hedgehog and the Android Gradle Plugin 8.0.0 or newer.</p><h4>Streamline profile generation with the Baseline Profile Gradle Plugin</h4><p>The Baseline Profile Gradle Plugin makes it easier to generate and maintain Baseline Profiles both during local development as well as CI. It performs all the necessary steps to generate and install a Baseline Profile into your application module.</p><p>To use the plugin, add an instrumented test module to your project and define a set of tests that navigate through your app to simulate critical user journeys. When you run the instrumented test, the Baseline Profile Gradle Plugin tracks all classes and methods that are executed during these user journeys and generates a Baseline Profile based on these classes and methods. It then copies the generated Baseline Profile into the application module’s source-set.</p><p>After applying the plugin, it can be configured with a new baselineProfile block in your build script. The generateBaselineProfile Gradle task runs all baseline profile tests for you. The resulting profile files are stored in a generated folder and can be accessed from there. These features remove friction from automating Baseline Profile generation, both locally and on a remote CI server. And by specifying a Gradle Managed Device to use when generating a profile, you don’t even need an attached physical device. The plugin’s DSL enables a highly configurable setup and enables you to automate and reproduce Baseline Profile generation.</p><p>Check out the <a href="https://github.com/android/performance-samples/tree/bpgp/MacrobenchmarkSample">code sample</a> (currently on a separate branch) and <a href="https://d.android.com/topic/performance/baselineprofiles/create-baselineprofile">guiding documentation</a> to get started.</p><h3>Create and manage multiple Baseline Profile source files with AGP 8+</h3><p>AGP 8 onwards supports easier generation of Baseline Profile with support for multiple source files, variant specific profiles, and support for the new Gradle plugin mentioned above. The default location for Baseline Profiles now is src/main/baselineProfiles/. Baseline Profile source files stored in this directory will be picked up and merged into your application. This enables you to store separate profile files for app startup and each distinct user journey.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q-7VBgdt3FZcrDGMb7nW7g.png" /><figcaption>Multiple Baseline Profile source files in the Macrobenchmark Sample</figcaption></figure><h3>Easier onboarding with the Android Studio Baseline Profile Generator Template</h3><p>To assist you getting started with Baseline Profiles, Android Studio Hedgehog (2023.1.1) adds the <strong>Baseline Profile Generator </strong>module wizard template. By using this template, your app can be set up with Baseline Profiles in a visually assisted way.</p><p>Get started by navigating to <strong>File &gt; New &gt; New Module </strong>and select <strong>Baseline Profile Generator</strong> from the list of templates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1s1qlJ-gTkiR6Ma-sTJIaA.png" /><figcaption>Baseline Profile Generator Wizard</figcaption></figure><p>When you’re finished, the template will have made several changes for you. It creates a new :baselineprofile test module containing basic generators and benchmarks. The BaselineProfileGenerator class creates a basic baseline profile for you and StartupBenchmarks can verify everything works as intended. Also, Baseline Profile Gradle plugin will be applied in relevant modules. Lastly, a dependency on androidx.profileinstaller will be added, to aid local verification and backwards compatibility.</p><p>From here, all you need to do is execute the <strong>Generate Baseline Profile</strong> run configuration, which runs included Baseline Profile generators and copies the generated profiles to src/release/generated/baselineProfile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*zyhhZyWSfoMmE5ofUgVKSw.png" /><figcaption>Generate Baseline Profile run configuration</figcaption></figure><p>The run configuration calls the :app:generateBaselineProfile task, looks for all Baseline Profiles generators and only runs these.</p><p>The BaselineProfileGenerator is very basic and does only start your app and wait for the <a href="https://developer.android.com/topic/performance/vitals/launch-time">app startup</a> to complete. We recommend creating a Baseline Profile for <em>each critical user journey</em> through your app. As user journeys vary between apps, it’s up to you to decide what to optimize. A good starting point is anything that’s directly tied to business results, such as sign up, login, checkout or other major actions your app offers. You can get inspiration from our <a href="http://github.com/android/performance-samples/tree/main/MacrobenchmarkSample">code samples</a>.</p><p>To get started, download <a href="https://developer.android.com/studio/preview">Android Studio Hedgehog Canary</a> today.</p><p>And for a guided tour through the whole onboarding process check out the updated codelab: <a href="https://developer.android.com/codelabs/android-baseline-profiles-improve">Improve app performance with Baseline Profiles</a>.</p><h3>Introducing Startup Profiles and Dex layout optimizations</h3><p>Starting with version 8.1, the Android Gradle Plugin (AGP) can pull code that’s required for app startup into the primary dex file of your app. This optimization is called dex layout optimization and helps to reduce dex page faults during app startup. This can significantly speed up app startup as only a single dex file needs to be loaded until the app has completed startup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*SbG7yTB_ZYUSCDZcAa2p_Q.png" /><figcaption>Before and after dex layout optimization</figcaption></figure><p>While AGP can create separate dex files for your app, it doesn’t know what fully defines startup for your app without your help. This is where Startup Profiles come in. You can think of Startup Profiles as a subset of Baseline Profiles that are specifically tailored to app startup. Both share the same format and use the same underlying technology. Since app startup differs for every application, libraries do not contribute to the Startup Profile.</p><p>Baseline Profiles provide performance gains of around 30 %, compared to an app that requires interpretation and JIT compilation, for example right after an update is pushed. Our early tests with Dex layout optimizations have shown an additional 30% performance improvement on top of Baseline Profile gains for app startup. This is especially beneficial since these gains are always seen in cold startups, even if your production app already has a well functioning cloud profile.</p><p>To make the most of Dex layout optimizations and Startup Profiles, you need to let the Android Framework know when your app is done with startup. If you don’t do anything, app startup will be considered done when the first frame is drawn. To make sure the Startup Profile contains information up to the point where your user can take over, use the reportFullyDrawn APIs. You can do this via the <a href="https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter">FullyDrawnReporter</a> or the Compose <a href="https://developer.android.com/reference/kotlin/androidx/activity/compose/package-summary#ReportDrawn()">ReportDrawn</a> APIs. Additionally, you need to define the end point for the startup benchmark at a point where you deem startup complete. Match the call to reportFullyDrawn with what you’re expecting to be displayed on screen at the point where the app is ready to be used.</p><p>You can read more about Dex layout optimizations and Startup profiles in the guiding <a href="http://d.android.com/topic/performance/baselineprofiles/dex-layout-optimizations">documentation</a>.</p><h3>New developments in the Macrobenchmark library</h3><p>The Macrobenchmark library enables you to measure app performance, create baseline profiles and monitor whether changes to your app make a difference to app performance. The 1.2.0 will graduate to a beta release soon. Here are some feature highlights.</p><h3>Utilizing new Android platform features in benchmarks</h3><p>From Android 13 and newer you can generate a Baseline Profile with the BaselineProfileRule on non-rooted devices or emulators.</p><p>From Android 14 and newer, target apps no longer need to be reinstalled between benchmark runs. This enables apps to save state, such as cache, session state or login tokens between runs. This change removes the need to inject these states manually before benchmarking, which would have required a rooted device.</p><h4>New APIs</h4><p>✨ Baseline Profile generation is no longer considered experimental ✨</p><p>You can remove the opt-in to experimental API annotation from your code when creating a baseline profile using the collectBaselineProfile method. But if you like to stay on experimental APIs, we have a new API for your consideration.</p><p>The newly introduced collectStableBaselineProfile runs and waits until a profile is considered stable for a given amount of iterations. This means that your app’s Baseline Profile will better reflect what’s going on in your app as a code path is executed.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/471e30b7537cdb12392457bc07165794/href">https://medium.com/media/471e30b7537cdb12392457bc07165794/href</a></iframe><h4>More powerful metrics with custom trace processing</h4><p>PerfettoTraceRule enables custom trace collection in tests other than benchmarks (requires API 23+). This is a powerful feature that will allow users to collect performance and timing data about tests.</p><p>PerfettoTraceProcessor enables querying trace contents, and is the engine behind all of the existing Macrobenchmark Metric APIs. Now it’s possible to use it with TraceMetric to define fully custom metrics in the same way Macrobenchmark does from anything information in a Perfetto system trace.. This is another powerful feature that will allow users to customize their benchmarks even further.</p><h3>Attributing Power consumption from benchmarks</h3><p>The new PowerMetric API can be used to measure energy consumption and power states. This is a useful feature that will allow users to track the energy consumption of their benchmarks.</p><h3>Bug fixes and other improvements</h3><p>The team behind Macrobenchmark also made a variety of other improvements to ergonomics, fixed bugs and improved overall behavior. To learn more, check out the <a href="https://d.android.com/macrobenchmark">documentation</a>. If you want to get more detail, you can find a full list of release notes with attached code and tracking issues <a href="https://developer.android.com/jetpack/androidx/releases/benchmark">here</a>.</p><h3>Android Studio Power Profiler</h3><p>Android Studio Hedgehog features a new Profiler which shows power consumption on physical devices, segmented by each sub-system (such as: Camera, GPS, and more). This data is made available when recording a System Trace and helps you to visually correlate power consumption of the device to the actions happening in your app. For example, you can A/B test batching API calls vs making individual API calls to optimize power consumption in the Cellular power rail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rOsO5sJy9PmCV3aDiTswcQ.png" /><figcaption>The new Power Profiler in Android Studio Hedgehog</figcaption></figure><p>To get started, use a Pixel 6+ device to <a href="https://developer.android.com/topic/performance/tracing">record a System trace</a> and load it into Android Studio, or use the profiler to capture a System trace directly from the attached device.</p><h3>Why you should focus on performance</h3><p>When working on application performance, finding the right starting point can be a challenge. Working with the Android developer community, we found that engineers sometimes lack the right information to justify working on app performance.</p><p>Improving performance has a number of benefits, both for your users and for your business. For users, a fast and responsive app means a better user experience. Your users will be able to get the information they need quickly and easily, and they’ll be more likely to come back to your app.</p><p>For your business, improved performance can lead to increased revenue and decreased costs. When users are happy with your app, they’re more likely to make purchases or take other actions that benefit your business. Additionally, a well-performing app can help you save money on development and maintenance costs.</p><h3>Next steps</h3><ol><li>Set your app up to use <a href="https://developer.android.com/topic/performance/baselineprofiles/overview">Baseline Profiles</a> with the new <a href="https://developer.android.com/topic/performance/baselineprofiles/create-baselineprofile#baseline-profile-gradle-plugin">Gradle plugin</a></li><li>Upgrade to Android Gradle Plugin 8+</li><li>Move existing Baseline Profiles into the new default directory src/main/baselineProfiles/</li><li>Download the <a href="https://developer.android.com/studio/preview">Android Studio Hedgehog</a> Canary to check out the Baseline Profile template and power profiler</li><li><a href="https://developer.android.com/codelabs/android-baseline-profiles-improve">Check out our updated codelab</a> for a guided tour</li><li>Use the Fully Drawn and collectStableBaselineProfile APIs for better Baseline Profiles</li><li>Get started with <a href="http://d.android.com/topic/performance/baselineprofiles/dex-layout-optimizations">Dex layout optimizations</a> for even more performance gains</li><li>Implement your own Macrobenchmark tests to measure how performance moves over time</li><li>Record a System trace on a Pixel 6+ device to view power consumption of different subsystems (Camera, GPS, CPU, etc)</li><li>👏 and share this article to help improve app performance for everyone</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21a1832c9fa3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/androiddevelopers/whats-new-in-android-performance-google-i-o-2023-edition-21a1832c9fa3">What’s new in Android Performance — Google I/O 2023 edition</a> was originally published in <a href="https://medium.com/androiddevelopers">Android Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MAD Skills Performance — Wrap Up]]></title>
            <link>https://medium.com/androiddevelopers/mad-skills-performance-wrap-up-33688abfc51f?source=rss-65fe4f480b1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/33688abfc51f</guid>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[mad-skills]]></category>
            <dc:creator><![CDATA[Ben Weiss]]></dc:creator>
            <pubDate>Wed, 07 Sep 2022 16:07:32 GMT</pubDate>
            <atom:updated>2022-09-07T16:07:32.781Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qdkZp112bKTGtQIN" /><figcaption>Illustration by Claudia Sanchez</figcaption></figure><h3><em>MAD Skills Performance — Wrap Up</em></h3><p>In August the MAD Skills video and blog series helping you to get started with Performance. Here’s the gist of what happened.</p><h3>Setting the scene</h3><p>When Introducing the MAD Skills series on Performance, we shared the model which we’re using to work with performance.</p><p>Our guidance is aligned with the three pillars: <em>Inspect</em>, <em>Improve</em>, <em>Monitor</em>.</p><p>This alignment and restructuring of our documentation helps to improve developer experience and make working with performance more approachable, especially for developers that are not very familiar with the area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*2GxtuTLhBX4J9eA4" /><figcaption>Inspect -&gt; Improve -&gt; Monitor &amp; repeat</figcaption></figure><p>You can find the updated guides and documentation on <a href="http://d.android.com/performance">d.android.com/performance</a>.</p><h4>The full story</h4><p><a href="https://medium.com/androiddevelopers/introducing-the-mad-skills-series-on-performance-7dbb26e8b17f">Introducing the MAD Skills series on Performance</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F6R0jrJp1Uwg%3Flist%3DPLWz5rJ2EKKc91i2QT8qfrfKgLNlJiG1z7&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D6R0jrJp1Uwg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F6R0jrJp1Uwg%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/24b803c95ae0cb2d9dd91dcdb6da29ce/href">https://medium.com/media/24b803c95ae0cb2d9dd91dcdb6da29ce/href</a></iframe><h3>Important Performance Metrics</h3><p>Here we cover important performance metrics around app startup and frame rate metrics, which bring in important data points for the remainder of the series.</p><p>The episode contains introductions to cold, warm and hot start, time to initial display and time to full display. It also covers why it’s important to keep work off the main thread and what frame rates to optimize for.</p><h4>The full story</h4><p><a href="https://medium.com/androiddevelopers/important-performance-metrics-c7dacf018eb3">Important Performance Metrics</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F8ORC7SeYF5E%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D8ORC7SeYF5E&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F8ORC7SeYF5E%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f93acb88f4abfdd24088791c60046407/href">https://medium.com/media/f93acb88f4abfdd24088791c60046407/href</a></iframe><h3>Inspecting Performance</h3><p><a href="https://medium.com/u/f557899ce692">Tomáš Mlynarič</a> introduces you to tools and methods that help with your code’s performance.</p><blockquote>When you inspect performance you make sure that what’s happening in your app aligns with what you expect to happen.</blockquote><p>We introduce different ways to inspect performance, from <em>passive</em>, through <em>manual</em> and finally <em>automated</em>.</p><p>A key takeaway from this episode is that you always should inspect performance with a <strong>release build and on a real device</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/0*uViU1K5SBPtuOoOM" /><figcaption>Always inspect release builds on a physical device</figcaption></figure><h4>The full story</h4><p><a href="https://medium.com/androiddevelopers/inspecting-performance-95b76477a3d7">Inspecting Performance</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F-Mgy_nTMCtc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D-Mgy_nTMCtc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F-Mgy_nTMCtc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ba0e325b01727bc11f0916ee3bd15d3/href">https://medium.com/media/7ba0e325b01727bc11f0916ee3bd15d3/href</a></iframe><h3>Improving Performance with Baseline Profiles</h3><p><a href="https://d.android.com/baseline-profiles">Baseline Profiles</a> help your app to start and run faster by optimizing critical code paths ahead of time. This allows for a smoother user experience.</p><p>This episode contains all the info to get you going with Baseline Profiles in a nutshell. First you’ll learn what a Baseline Profile is, how it improves app and library performance. Then <a href="https://medium.com/u/f557899ce692">Tomáš Mlynarič</a> shows you how to generate a baseline profile and how to measure the impact a new profile has on your app.</p><h4>The full story</h4><p><a href="https://medium.com/androiddevelopers/improving-performance-with-baseline-profiles-fdd0db0d8cc6">Improving Performance with Baseline Profiles</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FWWdDzXgrkmg%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DWWdDzXgrkmg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FWWdDzXgrkmg%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2e516498ad45b5e5ad6de1f9422e7db/href">https://medium.com/media/e2e516498ad45b5e5ad6de1f9422e7db/href</a></iframe><p>To get more detailed code, check out the <a href="http://github.com/android/performance-samples">samples</a> on GitHub or take the <a href="https://goo.gle/baseline-profiles-codelab">Macrobenchmarking Codelab</a> or <a href="https://goo.gle/baseline-profiles-codelab">Baseline Profiles Codelab</a> for hands-on guidance through the topic.</p><h3>Monitoring App Performance</h3><p>This episode is guiding you through best practices and provides guidance on tools that can be used to monitor app performance.</p><p>Performance can be monitored in a development environment or lab or in the field. We’re sharing best practices and tools to monitor your app’s performance.</p><blockquote>Monitoring helps you to verify that performance moves in the right direction.</blockquote><h4>The full story</h4><p><a href="https://medium.com/androiddevelopers/monitoring-app-performance-ebf9af4ebe36">Monitoring App Performance</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FGiBu21pP9I0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGiBu21pP9I0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FGiBu21pP9I0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5b4b545ec2a9f7f40c69efeec6a1cf5/href">https://medium.com/media/c5b4b545ec2a9f7f40c69efeec6a1cf5/href</a></iframe><h3>The Q&amp;A session</h3><p>On September 1st, we hosted a live streamed Q&amp;A session with <a href="/service/mailto:carmenjackson@google.com">Carmen Jackson</a>, <a href="/service/mailto:ccraik@google.com">Chris Craik</a>, <a href="/service/mailto:mlykotom@google.com">Tomáš Mlynarič</a> and <a href="/service/mailto:benweiss@google.com">Ben Weiss</a>.</p><p>During the hour-long stream we went over many questions on performance. You can re-watch the stream any time. The article will be published over the next days as well.</p><h4>The full story</h4><p>The Article will be added here once the article is published.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FhsK5kggwIcM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DhsK5kggwIcM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FhsK5kggwIcM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b7ba307eaa9e25d0d94068ac757b7166/href">https://medium.com/media/b7ba307eaa9e25d0d94068ac757b7166/href</a></iframe><h3>What to do now</h3><p>Read our updated developer guidance on performance: <a href="https://d.android.com/performance">https://d.android.com/performance</a></p><p><strong>Create a </strong><a href="https://d.android.com/baseline-profiles"><strong>Baseline Profile</strong></a><strong> for your app to improve startup and runtime performance.</strong></p><p>If you haven’t done so yet, check out the <a href="http://github.com/android/performance-samples">samples</a> on GitHub or take the <a href="https://goo.gle/baseline-profiles-codelab">Macrobenchmarking Codelab</a> or <a href="https://goo.gle/baseline-profiles-codelab">Baseline Profiles Codelab</a>.</p><p>To keep up to date on Android Performance, follow <a href="http://twitter.com/androiddev">@AndroidDev</a>, <a href="http://twitter.com/keyboardsurfer">@keyboardsurfer</a> and <a href="http://twitter.com/mlykotom">@mlykotom</a> on Twitter.</p><p>And keep an eye out for new MAD Skills episodes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33688abfc51f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/androiddevelopers/mad-skills-performance-wrap-up-33688abfc51f">MAD Skills Performance — Wrap Up</a> was originally published in <a href="https://medium.com/androiddevelopers">Android Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Monitoring App Performance]]></title>
            <link>https://medium.com/androiddevelopers/monitoring-app-performance-ebf9af4ebe36?source=rss-65fe4f480b1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebf9af4ebe36</guid>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[mad-skills]]></category>
            <dc:creator><![CDATA[Ben Weiss]]></dc:creator>
            <pubDate>Mon, 29 Aug 2022 20:27:26 GMT</pubDate>
            <atom:updated>2022-08-29T20:27:26.866Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GW7g7T1qx_Adm2D-" /><figcaption>Illustration by Claudia Sanchez</figcaption></figure><p>In this MAD Skills article on monitoring performance I’m guiding you through best practices and provide guidance on tools that can be used to monitor app performance.</p><blockquote>Monitoring performance verifies performance moves in the right direction.</blockquote><p>App performance can either be monitored in a lab environment, <em>before the app is released</em> and in the field, when users have <em>installed and actively use an app</em>.</p><p>The content in this article is also available as recording on YouTube</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FGiBu21pP9I0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGiBu21pP9I0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FGiBu21pP9I0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5b4b545ec2a9f7f40c69efeec6a1cf5/href">https://medium.com/media/c5b4b545ec2a9f7f40c69efeec6a1cf5/href</a></iframe><h3>Lab Monitoring</h3><p>Performance data gathered here is invaluable, because you can learn how an app performs <em>before</em> it hits users. This helps you limit possible business impact and overall impact on users. Data gathered in the lab can be used as a <strong>Go/No-Go </strong>signal. If performance metrics worsen between release you can use these as justification to postpone a release or block shipping a feature.</p><h4>Continuous Integration</h4><p>You can also have fast turnaround time thanks to continuous integration (CI). There are various CI servers and services available and I won’t compare them here.</p><p>By using a CI pipeline you can kick off a benchmark suite every time a commit lands onto a release branch, or maybe even before it gets merged onto your main branch. This way you can compare performance between releases and raise a red flag in case the metrics are above the threshold you decided on.</p><p>Make sure to run benchmarks on real devices. Instead of maintaining your own local device pool for testing, you can use a provider that offers testing on physical devices such as <a href="https://firebase.google.com/products/test-lab">Firebase Test Lab</a>.</p><p>Firebase Test Lab keeps devices connected and up to date so you don’t have to invest in your local test device setup. You can use the scripting interface to run benchmarks on every build and continuously see results.</p><h4>Step Fitting</h4><p>Whether you choose to run benchmarks on local devices or with a cloud provider, spotting regressions can be tricky at times. To automate reporting you have to set thresholds for each metric that you deem important and then compare it to a previously run benchmark. <strong>You will see performance fluctuate</strong>. Some builds might complete faster and some slower. Spotting whether an increase in runtime for a benchmark is a regression in your code requires you to compare more than two builds.</p><p>Within our public AndroidX Continuous Integration pipeline we have faced this problem in the past and came up with a viable solution to it.</p><p>Instead of comparing a single build to the previous one, we accumulate a set number of builds and compare builds before and after a change has landed in the codebase.</p><p>While this might take a handful of builds to spot a regression, the approach is very reliable and scales well, even with hundreds of libraries and engineers involved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*ACwPFx9kTl6aWvnf" /></figure><p>In his article on fighting regressions with benchmarks, Chris Craik describes exactly how step fitting works in our code base and how you can integrate it into your continuous integration pipeline.</p><p>The short version is:</p><ul><li>Write macrobenchmark tests</li><li>Run them on real devices</li><li>Collect and store the output metrics</li><li>Run the step fitting algorithm</li></ul><p>You can read all the details about step fitting in this article</p><p><a href="https://medium.com/androiddevelopers/fighting-regressions-with-benchmarks-in-ci-6ea9a14b5c71">Fighting Regressions with Benchmarks in CI</a></p><h3>Field Monitoring</h3><p>You can monitor your app’s performance once your users have started using it, with field monitoring in production.</p><h4>Android Vitals</h4><p>The easiest way to monitor production metrics is by looking at the data <a href="https://developer.android.com/topic/performance/vitals">Android Vitals</a> provides. Android Vitals offers anonymized and aggregated data over your installed user base, along with peer benchmarks so you can compare your app with others. To use Android Vitals, you don’t need to make any changes to your app’s code whatsoever. Simply upload it onto the Google Play Store and we’ll take care of the rest.</p><p>Android Vitals provides you with metrics on</p><ul><li>App Startup Time</li><li>Slow and Frozen Frames</li><li>Unresponsive Activities</li><li>Crashes</li><li>and more</li></ul><p>You can compare how your app is doing in different device categories such as Android operating system version, available RAM, CPU speed and others.</p><blockquote>It’s valuable to periodically check-in on the data provided by Android Vitals to see what could be improved.</blockquote><h4>Firebase Performance Monitoring</h4><p>And if you want more details, <a href="https://firebase.google.com/docs/perf-mon">Firebase Performance Monitoring</a> has you covered.</p><p>By adding the gradle plugin to your app, you can see information about cold start times, the rough source of slow and janky frames, and network request durations. All of this data is reported into the <a href="https://console.firebase.google.com/?hl=de">Firebase Console</a>.</p><pre>plugins {<br>  id(...)<br>  id(&quot;com.google.firebase.firebase-perf&quot;) version &quot;$version&quot;<br>}</pre><p>And you can get even more specific data using Firebase Performance Monitoring. Begin by adding the library dependency.</p><pre>dependencies {<br>  implementation(&quot;com.google.firebase:firebase-perf&quot;)<br>}</pre><p>Then, you can add your <strong>own trace points for any code within your app</strong>. Here we trace when data is loaded.</p><pre>Firebase.performance.newTrace(LOAD_DATA).trace {<br>  loadRemote()<br>  loadFromCache()<br>}</pre><p>By using the Kotlin extension trace function, the call site for loading data can be wrapped. This is a quick way to span multiple method calls.</p><p>Alternatively, you can use the AddTrace annotation on a method. This provides you with a way to trace a single method every time it is called and then report it to the Firebase Console.</p><pre>@AddTrace(name = &quot;loadRemote&quot;, enabled = true)<br>private fun loadRemote() { ... }</pre><blockquote>We are continuously expanding our suite of Jetpack libraries related to performance.</blockquote><h4>JankStats</h4><p>We have released the <a href="https://developer.android.com/topic/performance/jankstats">JankStats library</a> that enables gathering janky frames alongside metadata such as how the user got to the state where a frame had to be dropped. After you add the dependency to your app’s build file, install JankStats into an activity window by calling createAndTrack.</p><pre>override fun onCreate(savedInstanceState: Bundle?) {<br>  super.onCreate(savedInstanceState)<br>    JankStats.createAndTrack(window) { frameData -&gt;<br>    if (frameData.isJank) {<br>      logAndAddToReportingQueue()<br>    }<br>  }<br>}</pre><p>When a frame is considered to be janky by the libraries heuristic, you can log it and add it to your reporting queue.</p><p>JankStats holds on to state for you in a PerformanceMetricsState object.</p><pre>PerformanceMetricsState.getHolderForHierarchy(localView)</pre><p>Here you can add and remove state in key value pairs.</p><pre>metricsHolder.state?.putState(<br>  &quot;Interests:TabState&quot;,<br>  &quot;${tabState.currentIndex}&quot;<br>)<br>metricsHolder.state?.removeState(“Interests:TabState”)</pre><p>This enables you to add metadata such as navigation destinations, which make it easier for you to reproduce how the user reached the janky frame in the first place.</p><p>To see more usage of JankStats in action, <strong>check out the </strong><a href="https://github.com/android/nowinandroid"><strong>Now in Android</strong></a><strong> sample</strong>, where we have added jank tracking code to key areas such as scrolling through the authors list or the for you page.</p><h3>That’s all folks</h3><p>This concludes our second MAD Skills series on Performance. We have shown you <a href="https://medium.com/androiddevelopers/important-performance-metrics-c7dacf018eb3">important performance metrics</a> and how to <a href="https://medium.com/androiddevelopers/inspecting-performance-95b76477a3d7">inspect</a>, <a href="https://medium.com/androiddevelopers/improving-performance-with-baseline-profiles-fdd0db0d8cc6">improve</a> and monitor app and library performance around app startup and smooth runtime experiences.</p><blockquote>If you haven’t already, go and create a <a href="https://medium.com/androiddevelopers/improving-performance-with-baseline-profiles-fdd0db0d8cc6">Baseline Profile</a> for your app. It’s a quick way to make your app run faster and smoother.</blockquote><p>We’re aware that there’s much more to cover when talking about performance. And while we didn’t have time to cover everything in this series we continue to add more content to our developer guidance and samples.</p><p>Also, make sure to ask your questions in the video comments or on Twitter, using <a href="https://twitter.com/search?q=%23MADPerfQA">#MADPerfQA</a> to get answers directly from the Engineers working on Android Performance in our Q&amp;A session on Sept 1st.</p><p>And check out our previous MAD Skills series on performance debugging to get an edge on how you can inspect what’s going on in your code.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F_5LgIrd4O5g%3Flist%3DPLWz5rJ2EKKc-xjSI-rWn9SViXivBhQUnp&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D_5LgIrd4O5g&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F_5LgIrd4O5g%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3bd2bf571a2b763a0614983707b09295/href">https://medium.com/media/3bd2bf571a2b763a0614983707b09295/href</a></iframe><p>Go and check out our improved developer <a href="http://d.android.com/performance">documentation</a>, which we have been updating with MAD guidance.</p><p>To get more detailed code, check out the <a href="http://github.com/android/performance-samples">samples</a> on GitHub. And take the <a href="https://goo.gle/baseline-profiles-codelab">Macrobenchmarking Codelab</a> or <a href="https://goo.gle/baseline-profiles-codelab">Baseline Profiles Codelab</a> for hands-on guidance through the topics.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebf9af4ebe36" width="1" height="1" alt=""><hr><p><a href="https://medium.com/androiddevelopers/monitoring-app-performance-ebf9af4ebe36">Monitoring App Performance</a> was originally published in <a href="https://medium.com/androiddevelopers">Android Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Improving Performance with Baseline Profiles]]></title>
            <link>https://medium.com/androiddevelopers/improving-performance-with-baseline-profiles-fdd0db0d8cc6?source=rss-65fe4f480b1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdd0db0d8cc6</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mad-skills]]></category>
            <category><![CDATA[baseline-profiles]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Ben Weiss]]></dc:creator>
            <pubDate>Tue, 23 Aug 2022 18:02:21 GMT</pubDate>
            <atom:updated>2022-09-05T10:21:00.859Z</atom:updated>
            <content:encoded><![CDATA[<p>A quick rundown of Baseline Profiles</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WJ5hJ_W4pfZSpnQP" /><figcaption>Illustration by Claudia Sanchez</figcaption></figure><p>In this MAD Skills article on <strong>improving performance with Baseline Profiles</strong> you’ll learn what Baseline Profiles are and how they can be used to improve app startup and speed up runtime.</p><blockquote>Baseline Profiles help your app to start and run faster by optimizing critical code paths ahead of time. This allows for a smoother user experience.</blockquote><p>We have seen significant app launch and runtime improvements thanks to using Baseline Profiles. You can read on how <a href="https://android-developers.googleblog.com/2022/01/improving-app-performance-with-baseline.html">Google Maps improved their app launch time by up to 40 %</a> after introducing Baseline Profiles.</p><p>You can watch the accompanying video to this article here.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FWWdDzXgrkmg%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DWWdDzXgrkmg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FWWdDzXgrkmg%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2e516498ad45b5e5ad6de1f9422e7db/href">https://medium.com/media/e2e516498ad45b5e5ad6de1f9422e7db/href</a></iframe><h3>Baseline Profiles in a nutshell</h3><p>Baseline Profiles are a list of classes and methods that are ahead of time compiled and installed with your app. This means that your code does not need to be interpreted using the just-in-time (JIT) compiler when the app is used. This translates into startup time improvements, reduced jank, and overall improved runtime performance for end users.</p><p>Baseline Profiles can be generated for applications and bundled with the app that’s being shipped to users. But also libraries can create their own Baseline Profile and ship it with their AAR. The Baseline Profiles from libraries will be merged into an application’s Baseline Profile and then compiled into a single file, which is shipped with the app itself.</p><p>To speed up the development process, Baseline Profiles are not installed for debug builds but only for release builds. So, to see the performance gains of your profile, always verify it against a release build.</p><blockquote>Always verify performance gains in a release build.</blockquote><p>Jetpack Compose is a popular example for a library that <a href="https://developer.android.com/jetpack/compose/performance">provides a Baseline Profile</a>. By offering library consumers this profile, Jetpack Compose can minimize the impact of being an unbundled UI toolkit for release builds of an app.</p><h3>Generating a Baseline Profile</h3><p>The <a href="https://developer.android.com/topic/performance/benchmarking/macrobenchmark-overview">Macrobenchmark library</a> comes with a rule to <a href="https://developer.android.com/reference/kotlin/androidx/benchmark/macro/junit4/BaselineProfileRule">generate Baseline Profiles</a> for you. By using UIAutomator you can drive the profile generator through an app’s critical user journeys. The API calls made in the app will be captured and integrated into the Baseline Profile which the Macrobenchmark library creates.</p><p>The minimum viable setup for a baseline profile generator looks like this.<br>Below code will generate a baseline profile for you and you can implement clickThroughUserJourney() to guide the generator to more complex scenarios.</p><pre>@ExperimentalBaselineProfilesApi<br>@RunWith(AndroidJUnit4::class)<br>class BaselineProfileGenerator {<br>    @get:Rule<br>    val baselineProfileRule = BaselineProfileRule()<br><br>    @Test<br>    fun startup() = baselineProfileRule.collectBaselineProfile(<br>        packageName = &quot;com.example.app&quot;<br>    ) {<br>        pressHome()<br>        startActivityAndWait()<br>        clickThroughUserJourney()<br>    }<br>}</pre><p>You can see a how a trivial Baseline Profile generator is set up <a href="https://github.com/android/performance-samples/blob/main/MacrobenchmarkSample/macrobenchmark/src/main/java/com/example/macrobenchmark/TrivialBaselineProfileBenchmark.kt">in our sample app on GitHub</a>. And the <a href="https://github.com/android/nowinandroid/blob/main/benchmark/src/main/java/com/google/samples/apps/nowinandroid/baselineprofile/BaselineProfileGenerator.kt">Now in Android sample app</a> has a more complex Baseline Profile setup.</p><p>To learn more about the Macrobenchmark library and how to set up a benchmark, read the previous article in this series, or watch the video.</p><p><a href="https://medium.com/androiddevelopers/inspecting-performance-95b76477a3d7">Inspecting Performance</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F-Mgy_nTMCtc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D-Mgy_nTMCtc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F-Mgy_nTMCtc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ba0e325b01727bc11f0916ee3bd15d3/href">https://medium.com/media/7ba0e325b01727bc11f0916ee3bd15d3/href</a></iframe><p>The <a href="https://goo.gle/baseline-profiles-codelab">codelab to create a Baseline Profile guides</a> you through the latest best practices to get started and leaves you with a first Baseline Profile.</p><h3>While you wait for the next article</h3><p>The next article is all about <strong>monitoring app performance</strong>.</p><p>Go and check out our improved developer <a href="http://d.android.com/performance">documentation</a>, which we have been updating with MAD guidance.</p><p>To get more detailed code, check out the <a href="http://github.com/android/performance-samples">samples</a> on GitHub or take the <a href="https://goo.gle/baseline-profiles-codelab">Macrobenchmarking Codelab</a> or <a href="https://goo.gle/baseline-profiles-codelab">Baseline Profiles Codelab</a> for hands-on guidance through the topics.</p><p>Make sure to ask your questions in the video comments or on Twitter, using <a href="https://twitter.com/search?q=%23MADPerfQA">#MADPerfQA</a> to get answers directly from the Engineers working on Android Performance in our Q&amp;A session on Sept 1st</p><p>And check out the full MAD Skills series on performance debugging to get an edge on how you can inspect what’s going on in your code.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F_5LgIrd4O5g%3Flist%3DPLWz5rJ2EKKc-xjSI-rWn9SViXivBhQUnp&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D_5LgIrd4O5g&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F_5LgIrd4O5g%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3bd2bf571a2b763a0614983707b09295/href">https://medium.com/media/3bd2bf571a2b763a0614983707b09295/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdd0db0d8cc6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/androiddevelopers/improving-performance-with-baseline-profiles-fdd0db0d8cc6">Improving Performance with Baseline Profiles</a> was originally published in <a href="https://medium.com/androiddevelopers">Android Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Inspecting Performance]]></title>
            <link>https://medium.com/androiddevelopers/inspecting-performance-95b76477a3d7?source=rss-65fe4f480b1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/95b76477a3d7</guid>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[mad-skills]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Ben Weiss]]></dc:creator>
            <pubDate>Mon, 15 Aug 2022 19:03:07 GMT</pubDate>
            <atom:updated>2022-09-05T10:20:50.207Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pYhUVEoLr0N1nr7x" /><figcaption>Illustration by Claudia Sanchez</figcaption></figure><p>This MAD Skills article on <strong>inspecting performance</strong> introduces you to tools and methods that help when your code’s performance. When you inspect performance you make sure that what’s happening in your app aligns with what you expect to happen.</p><p>You can also watch this article as a MAD Skills video.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F-Mgy_nTMCtc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D-Mgy_nTMCtc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F-Mgy_nTMCtc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6ca1a917dad5d93e212ac679371e1d8/href">https://medium.com/media/b6ca1a917dad5d93e212ac679371e1d8/href</a></iframe><p>Inspecting performance is ensuring that what’s happening in your app aligns with your expectations.</p><p>We’re differentiating performance inspection in three stages: Passive, manual and automated. Each has its own place to shine and reason to be used.</p><h3>Passive performance inspection</h3><p>When we speak of passive performance inspection, we mean that there’s no extra work necessary to spot a performance problem, other than running it and looking at the existing output. Some problems, such as frozen frames and slow behavior can be seen when interacting with the app directly. This can help you find areas to improve your app, especially when running your app on a device with low specs such as CPU power or RAM.</p><p>Next to running the app and evaluating jank directly on screen, you can use <strong>logcat</strong> to check for slow and dropped frames, which are logged automatically for you.</p><h4>Slow frames</h4><p>Use the new <strong>Logcat</strong> in Android Studio to filter for the Choreographer tag and you can see dropped frames while running the app. As soon as more than 30 frames have been skipped, it’ll be logged.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/0*1092nOLmIIBZ9C8p" /></figure><h4>Frozen frames</h4><p>Frames which take longer than 700ms to render will be logged with the OpenGLRenderer tag and some more detailed information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/0*s7Ln3TzGMdY2EBMi" /></figure><h4>Non-responsive Activity</h4><p>And if your app is unresponsive for more than 5 seconds, you’ll see the Activity Non-Responsive (ANR) dialog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/0*QNVXxTLD044nvTcT" /></figure><h4>App launches</h4><p>You can also see app launch durations in logcat, by filtering for the ActivityTaskManager tag.</p><p>Time to Initial Display (TTID) will be logged with Displayed.</p><p>Time to Full Display (TTFD) is logged with Fully Drawn.</p><blockquote>App launch times of less than 500 ms (0.5 seconds) are desirable, as users perceive longer launch durations negatively.</blockquote><p>You can read more about these metrics in the previous article on <a href="https://medium.com/androiddevelopers/important-performance-metrics-c7dacf018eb3?source=rss-------1">MAD Skills Performance Metrics</a>.</p><p><a href="https://medium.com/androiddevelopers/important-performance-metrics-c7dacf018eb3">Important Performance Metrics</a></p><p>Passive inspection is a great starting point to see if there are problems and can help you to roughly point in the right direction of a problem. To actually qualify which part of an app caused the problem, passive inspection rarely is enough. You’ll need to inspect your app’s code actively.</p><h3>Manual performance inspection</h3><p>When you have a rough understanding which parts of an app are not performing as you expect, it’s time to manually inspect what’s going on in depth. Android Studio ships with a suite of profilers which are ready to help you inspect what’s going on in your app.</p><p>Android Studio’s Profilers have parallels to the Debugger. What the Debugger is for stepping through code, looking at parameter and property values, the Profiler is for inspecting CPU, Memory, Network usage as well as possible sources of Jank.</p><blockquote>The Profiler helps you get a detailed understanding of where a problem occurs.</blockquote><p>And while you are developing an app, the debugger allows you to attach to an app during development and inspect problems in depth, using builds that are debuggable is most likely giving wrong performance data.</p><h3>Always inspect release builds on real devices</h3><p>Debuggable builds provide many features useful for development, like live edit, applying changes without reinstalling the app, or inspecting property values, changing data and otherwise using Android Studio’s debugging capabilities.</p><p>Builds that are marked as debuggable also add a performance overhead to your app. This makes performance metrics unreliable. Something that might look performing poorly on a debuggable build, actually can work well on a release build.</p><p>To verify whether a performance issue exists in a production environment or only during development, make sure to verify it on a release build release version of your app.</p><p>Set your build variant to release by switching the Build Variant to your most production like build. The Now in Android sample uses `prodRelease` for this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/0*i5DNewcSBcKK9EkF" /></figure><p>Also, in your AndroidManifest.xml, mark the application as profileable. This allows profilers to inspect what’s going on in a production build.</p><pre>&lt;!--AndroidManifest.xml--&gt;</pre><pre>&lt;manifest...<br>  &lt;application...<br>    &lt;profileable android:shell=”true” tools:targetApi=”q” /<br>  &lt;/application&gt;<br>&lt;/manifest&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/0*Of4FQdg4sMVZwZBR" /><figcaption>Always inspect release builds on a physical device</figcaption></figure><blockquote>You need to inspect release builds on a physical device.</blockquote><p>The Android Emulator has come a long way. It boots quickly, runs smoothly and provides a seamless experience during app development. But when it comes to measuring performance, the Android Emulator is not the right tool.</p><p>When you inspect performance on an Emulator, you’re not measuring against an Android device with physical constraints but against the host machine’s capabilities. If a host system is under heavy load, the inspected app will be less performant.</p><blockquote>Inspecting performance on a physical device will provide you with consistently useful data.</blockquote><h3>More MAD Skills on manual performance inspection</h3><p>Because manual inspection of performance is a full topic on its own, we produced an entire series which aims at helping you to get a deep understanding on manual performance debugging. You can check it out here.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fvideoseries%3Flist%3DPLWz5rJ2EKKc-xjSI-rWn9SViXivBhQUnp&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fplaylist%3Flist%3DPLWz5rJ2EKKc-xjSI-rWn9SViXivBhQUnp&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F_5LgIrd4O5g%2Fhqdefault.jpg%3Fsqp%3D-oaymwEWCKgBEF5IWvKriqkDCQgBFQAAiEIYAQ%3D%3D%26rs%3DAOn4CLCt0_Ud03kX9ENJb4gWE-GoQGbdxg%26days_since_epoch%3D19351&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="853" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4721c8b1384c2a46ab06effe6017a38/href">https://medium.com/media/e4721c8b1384c2a46ab06effe6017a38/href</a></iframe><h3>Automated performance inspection</h3><p>Passive and manual inspection are important steps when inspecting performance. The third way to inspect performance, and likely the most reliable one to give you consistent results, is automated performance inspection. With automated performance inspection, you can reliably run the same steps in a flow time after time.</p><blockquote>Automated inspection can help prevent a performance issue before it is shipped to your users.</blockquote><p>And while the automation process takes a little setup, you get peace of mind when it comes to ensuring your app’s performance is consistent. We provide the Jetpack Macrobenchmark library to help you automate performance inspection. This library allows you to automate inspecting performance of entire user flows. When using the Jetpack Macrobenchmark library, you can measure key metrics such as app startup, frame timing, and other performance metrics.</p><h4>Getting Started with Jetpack Macrobenchmark</h4><p>All you need to get started with Jetpack Macrobenchmark is a recent version of Android Studio. We recently released a <a href="https://goo.gle/baseline-profiles-codelab">codelab that guides you through the process</a> of creating and running your first Macrobenchmark.</p><p>Also, the overall <a href="https://developer.android.com/topic/performance/benchmarking/macrobenchmark-overview">guidance on how to create a Macrobenchmark</a> gives you the latest instruction on getting started.</p><h3>While you wait for the next article</h3><p>In the next article we’ll introduce you to a fast way to improve your app’s performance with <a href="https://developer.android.com/topic/performance/baselineprofiles">Baseline Profiles</a>.</p><p>Go and check out our improved developer <a href="http://d.android.com/performance">documentation</a>, which we have been updating with MAD guidance.</p><p>To get more hands on, check out the <a href="http://github.com/android/performance-samples">samples</a> on GitHub.</p><p>Or take the <a href="https://goo.gle/baseline-profiles-codelab">Macrobenchmarking Codelab</a> or <a href="https://goo.gle/baseline-profiles-codelab">Baseline Profiles Codelab</a> for hands on guidance through the topics.</p><p>Also, make sure to ask your questions in the video comments or on Twitter, using <a href="https://twitter.com/search?q=%23MADPerfQA">#MADPerfQA</a> to get answers directly from the Engineers working on Android Performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95b76477a3d7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/androiddevelopers/inspecting-performance-95b76477a3d7">Inspecting Performance</a> was originally published in <a href="https://medium.com/androiddevelopers">Android Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Important Performance Metrics]]></title>
            <link>https://medium.com/androiddevelopers/important-performance-metrics-c7dacf018eb3?source=rss-65fe4f480b1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7dacf018eb3</guid>
            <category><![CDATA[mad-skills]]></category>
            <category><![CDATA[metrics]]></category>
            <category><![CDATA[android-performance]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[apps]]></category>
            <dc:creator><![CDATA[Ben Weiss]]></dc:creator>
            <pubDate>Thu, 11 Aug 2022 19:03:02 GMT</pubDate>
            <atom:updated>2022-09-05T10:20:40.673Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Be4McwKM10m3XAPmLEWG3Q.png" /><figcaption>Illustration by Claudia Sanchez</figcaption></figure><p>Before you begin to work with performance effectively, we recommend you make yourself familiar with key performance metrics. By understanding what metrics you should look at, you will make inspecting, improving and monitoring performance easier.</p><p>This MAD Skills article on <strong>important performance metrics</strong> will introduce you to <strong>startup</strong> and <strong>frame rate metrics</strong> and bring in important data points for the rest of this series on performance. App startup and creating a smooth user experience have shown to have a lasting impact on user satisfaction and applications’ individual business metrics, which is why we have chosen these areas as focal points for this article.</p><p>Later in this series we have tools and libraries lined up to make it easier for you to inspect, improve, and monitor performance.</p><p>You can watch the accompanying video to this article here.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F8ORC7SeYF5E%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D8ORC7SeYF5E&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F8ORC7SeYF5E%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/329c962242f2bc3cdd8fe66ef254f0df/href">https://medium.com/media/329c962242f2bc3cdd8fe66ef254f0df/href</a></iframe><h3>Startup phases</h3><p>Application startups are the first point of interaction with your user. Making a lasting and positive first impression is even more important at scale. So your goal is to make the app startup as fast, seamless and smooth as possible.</p><blockquote>App startup can be measured in three phases: Cold, warm and hot start.</blockquote><p>The startup phase is determined by the current state of your app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*RNrYCsNHSe5Y4YJY" /><figcaption>App startup phases</figcaption></figure><h4>Cold start</h4><p>A cold start begins when the application’s process is created. This is what users experience when they install your app and then launch it for the first time, launch the app after restarting their device or restart the app after the system has completely stopped it for one reason or another.</p><p>During a cold start, Application.onCreate() is called. Everything your app needs to get started is loaded from disk. When a cold start begins, memory caches are empty as well. Cold starts are the slowest startup type, because they start at process creation and end at the same time a hot start finishes. To experience a cold start of your app, force-close it and then open it again from the launcher.</p><blockquote>Cold starts should be faster than 500 milliseconds.</blockquote><p>When a cold start takes longer than 500 milliseconds, your users are going to notice and might get increasingly impatient and might decide to move away from your app. So keeping cold starts as fast as possible is extremely important.</p><h4>Warm start</h4><p>A warm start is measured from the point when Activity.onCreate() is called, just before your view hierarchy is inflated.</p><p>At this point, some resources are already inflated and memory caches warmed up.</p><blockquote><em>Warm starts usually take place when you open an app after the activity was destroyed, but the app’s process is still running.</em></blockquote><p>This could happen if an app has been running in the background for a while, but not long enough for the system to kill the entire process. Also, whenever an orientation change forces the activity to be destroyed and re-created, that’s a warm start.</p><h4>Hot start</h4><p>The final and shortest app startup type is called hot start. During a hot start, an app that is running, such an activity that was paused, becomes visible to the user and enters the started state.</p><p>Here the first frame is ready to be drawn and Activity.onStart() is called. A hot start can happen when you’re switching back and forth between apps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*VVYrHNh4rECJoPsY" /></figure><p>Due to the nature of startup types, a cold start takes the most time. Warm and hot starts will be shorter.</p><blockquote>All three startup types, cold, warm and hot, are measured from their corresponding starting point to at least one of two end states.</blockquote><h3>Startup end states</h3><h4>Time to Initial Display</h4><p>The default app startup end state is called Time to Initial Display. Or <strong>TTID</strong> for short. It is automatically reported when the first frame of your application is ready to be drawn.</p><p>You can also see TTID by opening logcat and looking for the ActivityTaskManager tag with value Displayed. It will tell you how much time it took to display a specific activity. Because this is reported automatically, there’s nothing for you to configure. Every app is reporting this by default.</p><h4>Time to Full Display</h4><p>While time to initial display is reported automatically, the next state can be customized. It is called time to full display, or <strong>TTFD</strong>. Time to full display is an optional metric that Android can use to further optimize your app’s startup time. It is also used when running startup benchmarks on your app.</p><p>TTFD is also visible in logcat with the ActivityTaskManager tag. Look for ActivityTaskManager: Fully drawn.</p><p>You should report time to full display when everything is drawn on screen, and the data required for the user to interact with the app is available.</p><blockquote>The API to use is Activity’s reportFullyDrawn()</blockquote><p>reportFullyDrawn is not tied to an Activity lifecycle method and you must pick the right time to call the API that makes sense for your app.</p><p>And while it’s important to call the method around the time your app is ready to be used, <em>being absolutely precise on a frame level is not required</em>.</p><p>The <a href="http://github.com/android/nowinandroid">Now in Android</a> sample app is considered to be fully drawn when both the interests and feed have been loaded.</p><p>Once these two states are met, we call reportFullyDrawn when the current local view is ready to be drawn. You can check out the code in <a href="https://github.com/android/nowinandroid/blob/bc2fc8bb5e07139562a523fa33509d405b98d2b6/feature-foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt#L168">more detail on GitHub</a>.</p><h3>Frame Timing Metrics</h3><p>Making sure you don’t drop frames is very important for a smooth user experience. Most frames aren’t dropped in a static state but when the user is scrolling or you’re otherwise animating content. If an app is doing too much work on the main thread to meet the frame timing window, slow and frozen frames are the result.</p><p>We call this behavior Jank. Jank can be extremely frustrating so it’s important to know how to avoid it.</p><h4>Frame rates</h4><p>The screen can be drawn many times per second. The amount of re-draws per second is called frame rate.</p><p>Historically, Android devices came with a refresh rate of 60 frames per second. That gives your app 1/60th of a second to perform work on the main thread before a frame will be delayed or eventually has to be dropped. More recently, the frame rates have increased to 90 and even 120 frames per second.</p><p>And devices can also switch between different frame rates depending on a user’s choice, the developer’s decision, or even the device’s power or thermal state.</p><p>Within our Modern Android Development guides, we recommend you optimize for a frame rate of at least 90 frames per second. This means all the work in between frames has to fit in a window of less than 11.1 milliseconds. <em>And that’s very, very little time.</em></p><blockquote>A great way to achieve a high frame rate is to keep as much work as possible off the main thread.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*BByWrku9g21L02tR" /><figcaption>Different frame rates for an Android device</figcaption></figure><h3>While you wait</h3><p>In the next article we’ll introduce you to inspecting performance issues in detail.</p><p>Also, make sure to check out our full MAD Skills series on performance debugging to get an edge on how you can inspect what’s going on in your code.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F_5LgIrd4O5g%3Flist%3DPLWz5rJ2EKKc-xjSI-rWn9SViXivBhQUnp&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D_5LgIrd4O5g&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F_5LgIrd4O5g%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3bd2bf571a2b763a0614983707b09295/href">https://medium.com/media/3bd2bf571a2b763a0614983707b09295/href</a></iframe><p>Go and check out our improved developer <a href="http://d.android.com/performance">documentation</a>, which we have been updating with MAD guidance.</p><p>To get more hands on, check out the <a href="http://github.com/android/performance-samples">samples</a> on GitHub.</p><p>Or take the <a href="https://goo.gle/baseline-profiles-codelab">Macrobenchmarking Codelab</a> or <a href="https://goo.gle/baseline-profiles-codelab">Baseline Profiles Codelab</a> for hands on guidance through the topics.</p><p>Also, make sure to ask your questions in the video comments or on Twitter, using <a href="https://twitter.com/search?q=%23MADPerfQA">#MADPerfQA</a> to get answers directly from the Engineers working on Android Performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7dacf018eb3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/androiddevelopers/important-performance-metrics-c7dacf018eb3">Important Performance Metrics</a> was originally published in <a href="https://medium.com/androiddevelopers">Android Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing the MAD Skills series on Performance]]></title>
            <link>https://medium.com/androiddevelopers/introducing-the-mad-skills-series-on-performance-7dbb26e8b17f?source=rss-65fe4f480b1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dbb26e8b17f</guid>
            <category><![CDATA[mad-skills]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Ben Weiss]]></dc:creator>
            <pubDate>Wed, 10 Aug 2022 22:03:02 GMT</pubDate>
            <atom:updated>2022-09-05T10:20:23.243Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Be4McwKM10m3XAPmLEWG3Q.png" /><figcaption>Illustration by Claudia Sanchez</figcaption></figure><p>Performance spans every aspect of Android development, and as part of Modern Android Development we’re aiming to make it more approachable and user-friendly. We have also found direct correlations between improved app performance, user satisfaction and business metrics.</p><p>So, it’s time for another series of <strong>MAD Skills on Performance</strong>.</p><p>We are going to release episodes throughout August, ending with a live Q&amp;A session on YouTube with Engineers working on Android Performance.</p><p>Read on and follow this series to learn about Modern Android Performance. Next to articles we’re also publishing videos, the first of which is available here.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F6R0jrJp1Uwg%3Flist%3DPLWz5rJ2EKKc91i2QT8qfrfKgLNlJiG1z7&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D6R0jrJp1Uwg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F6R0jrJp1Uwg%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/24b803c95ae0cb2d9dd91dcdb6da29ce/href">https://medium.com/media/24b803c95ae0cb2d9dd91dcdb6da29ce/href</a></iframe><h3>Here’s what’s in the pipeline</h3><p>In this series we’re going to introduce you to metrics that are important when working with performance. We’ll use these metrics and introduce you to tools, libraries and best practices that help you inspect, improve and monitor your app’s startup time and provide a smooth user experience.</p><p>We’ll share how to create and use <a href="https://developer.android.com/topic/performance/baselineprofiles"><strong>Baseline Profiles</strong></a>.</p><p>This new technology has already helped several top partners improve their app startup time by an average of 30 percent. Using Baseline Profiles enables Ahead Of Time compilation of critical user journeys and provides improved runtime experience on top of startup speed improvements.</p><blockquote>Baseline profiles are production ready and can help your code run faster as well.</blockquote><p>Check out the <a href="http://github.com/android/nowinandroid">Now in Android</a> and <a href="http://github.com/android/performance-samples">Performance Samples</a> to see how to set up a Baseline Profile. You can also follow the new <a href="https://goo.gle/baseline-profiles-codelab">Baseline Profiles Codelab</a> to get a guided path to creating your own.</p><p>We will also cover new developments in <a href="https://developer.android.com/studio/profile/android-profiler">Android Studio profilers</a>, how the <a href="https://developer.android.com/topic/performance/benchmarking/macrobenchmark-overview">Jetpack Macrobenchmark</a> library helps you to keep track of your app’s performance, and introduce you to more libraries and products that help you monitor your code’s performance during development and in production.</p><p>We’ll show you how to use <a href="https://firebase.google.com/docs/perf-mon">Firebase Performance Monitoring</a> and how <a href="https://developer.android.com/topic/performance/vitals">Android Vitals</a> helps you to stay on top of field metrics. And we’ll give you a sneak peek into gathering jank metrics with the new <a href="https://developer.android.com/topic/performance/jankstats">JankStats</a> library.</p><h3>Modern mental model for Performance</h3><p>We made our guidance more approachable by introducing a new mental model for performance. All of our guidance is now aligned with three pillars:</p><ul><li>Inspect</li><li>Improve</li><li>Monitor</li></ul><p>These pillars provide you with a structured approach to performance in a closed feedback loop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*lgYOodUPo1KMmXwe" /><figcaption>Inspect -&gt; Improve -&gt; Monitor &amp; repeat</figcaption></figure><p><strong>Inspecting Performance </strong>helps you understand what’s going on in your app.</p><p>With that you can see what’s happening in your app and how that aligns with what you expect to happen.</p><p>The <strong>Improving Performance</strong> pillar consists of tools, libraries, and guidance to help your code gain a performance boost.</p><p>When <strong>Monitoring Performance</strong>, you’re able to verify whether implemented improvements are actually making performance metrics move in the right direction.</p><p>It can also give you more data for the next inspection cycle.</p><h4>There’s more</h4><p>Performance metrics can include more than just improving App Startup, and creating a smooth, jank free experience.</p><p>Reducing <strong>battery drain</strong>, being smart about <strong>data usage</strong> and caching, decreasing <strong>application size</strong>, and creating an overall <strong>crash free experience</strong> are also important when working with performance.</p><p>And while we won’t cover all of these areas in this MAD Skills series, you can find detailed information in our <a href="https://developer.android.com/topic/performance/improving-overview#solving_common_problems">developer guides</a>, which we update regularly.</p><h3>Partner Success Stories</h3><p>We have seen time and time again, working with key partners, that improving your app’s performance has a direct impact on user retention, better ratings, and improved business metrics.</p><p>Zomato has seen an average of 30 % startup speed improvement and found improving app performance to be a key business growth recipe.<br><a href="https://developer.android.com/stories/apps/zomato">Read the story here</a>.</p><p>Google Maps has used Baseline Profiles to improve their app startup and runtime by up to 40 %, which in turn improved searches by over 2 %.<br><a href="https://android-developers.googleblog.com/2022/01/improving-app-performance-with-baseline.html">Here’s the full story</a>.</p><h3>While you wait</h3><p>Make sure to check out our full MADSKills series on performance debugging to get an edge on how you can inspect what’s going on in your code.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F_5LgIrd4O5g%3Flist%3DPLWz5rJ2EKKc-xjSI-rWn9SViXivBhQUnp&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D_5LgIrd4O5g&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F_5LgIrd4O5g%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3bd2bf571a2b763a0614983707b09295/href">https://medium.com/media/3bd2bf571a2b763a0614983707b09295/href</a></iframe><p>Also, our improved developer <a href="http://d.android.com/performance">documentation</a> has been updated recently, so go and check it out.</p><p>Check out the <a href="http://github.com/android/performance-samples">samples</a> on GitHub or take the <a href="https://goo.gle/baseline-profiles-codelab">Macrobenchmarking Codelab</a> or <a href="https://goo.gle/baseline-profiles-codelab">Baseline Profiles Codelab</a> for hands on guidance through the topics.</p><p>Also, make sure to ask your questions in the video comments or on Twitter, using <a href="https://twitter.com/search?q=%23MADPerfQA"><strong>#MADPerfQA</strong></a> to get answers directly from the Engineers working on Android Performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dbb26e8b17f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/androiddevelopers/introducing-the-mad-skills-series-on-performance-7dbb26e8b17f">Introducing the MAD Skills series on Performance</a> was originally published in <a href="https://medium.com/androiddevelopers">Android Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WorkManager 2.5.0 stable released]]></title>
            <link>https://medium.com/androiddevelopers/workmanager-2-5-0-stable-released-701b668cd064?source=rss-65fe4f480b1c------2</link>
            <guid isPermaLink="false">https://medium.com/p/701b668cd064</guid>
            <category><![CDATA[workmanager]]></category>
            <category><![CDATA[jetpack]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Ben Weiss]]></dc:creator>
            <pubDate>Wed, 27 Jan 2021 20:02:56 GMT</pubDate>
            <atom:updated>2021-02-24T10:59:08.287Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tytX6WPDFQAXOwzOj6qEAw.png" /></figure><h3>Using WorkManager in multi-process apps</h3><p><strong>📝</strong> The recent release of WorkManager 2.5.0 enables easier usage in a multi-process environment and provides several stability improvements.</p><p>So if you have an app that manages multiple processes, and you need a robust way to manage background work (<em>no more initialization errors </em>️️⚠), then this is the release for you.</p><p>There are a few changes you’ll need to make to your code, so read on to find out more.</p><blockquote>At the end of this article I’ll also list some other behavior changes and newest additions in this version of the WorkManager library.</blockquote><h3>Introducing: work-multiprocess</h3><p>The new multiprocess artifact introduces performance gains by unifying job scheduling to a single process. To get started, add it to your app.</p><pre>Implementation &quot;androidx.work:work-multiprocess:2.5.0&quot;</pre><p>You can now <a href="https://developer.android.com/topic/libraries/architecture/workmanager/advanced/custom-configuration">choose</a> the designated process that WorkManager uses to enqueue WorkRequests, and run its in-process scheduler.</p><p>A configuration using Configuration.Provider can look like this.</p><pre>class MyApplication() : Application(), Configuration.Provider {  override fun getWorkManagerConfiguration() =<br>    Configuration.Builder()<br>      .setDefaultProcessName(&quot;<strong><em>com.example:remote</em></strong>&quot;)<br>      .build()<br>}</pre><blockquote><strong>Note</strong>: The parameter on setProcessName requires you to pass the fully qualified process name, consisting of your app’s package name, followed by a colon and then the host’s process name, e.g. com.example:remote.</blockquote><p>When using work-multiprocess you also want to use RemoteWorkManager instead of WorkManager to manage your work requests. <a href="https://developer.android.com/reference/androidx/work/multiprocess/RemoteWorkManager">RemoteWorkManager</a> will always reach out to the designated process to enqueue work for you. This ensures that you don’t accidentally initialize a new WorkManager in the calling process. The In-process scheduler also runs in the same designated process.</p><h4><strong>Benefits</strong></h4><p>With WorkManager configured like this and using RemoteWorkManager to schedule your jobs, you can enjoy your work being managed faster and more reliably in your multi-process app. This is because SQLite <a href="https://en.wikipedia.org/wiki/Resource_contention">contention</a> can be vastly reduced (because we no longer rely on file based locks) and job reconciliation across processes won’t be necessary any longer since your app will only have a single WorkManager instance running in a process that you can designate.</p><h3>Behavior changes 🔀</h3><h4><strong>Job reconciliation</strong></h4><p>Previously, when ActivityManager couldn’t instantiate the JobService to start a job, that job would get dropped silently because of an underlying bug in the platform. WorkManager now ensures that there is a backing scheduler job for every single WorkRequest when an Application instance is created by reconciling WorkRequest objects with jobs.</p><h4><strong>Limit internal database growth</strong></h4><p>We saw that one of the causes of app crashes was that the device ran out of storage. This happened mainly on devices that had low storage in the first place. However, when apps scheduled <strong>a lot</strong> of work, WorkManager was partially responsible for the device running low on storage.</p><blockquote>Completed jobs were recorded in an internal WorkManager database for 7 days by default. This time has been reduced to 1 day, which dramatically reduces the database size.</blockquote><p>While we shortened the buffer duration, you can control how long your job should be remembered by using the keepResultsForAtLeast() API.</p><h3>New testing API ✨</h3><p>If you’re using ListenableFuture with WorkManager, then testing got easier — the TestListenableWorkerBuilder Kotlin extension now takes in any class extending ListenableWorker, providing you with more flexibility during testing.</p><h3>Bug fixes 🐛</h3><p>In addition to new features, this release also contains several bug fixes that improve the stability, reliability, and performance of WorkManager. You can read up on all changes as well as fixed bugs in the <a href="https://developer.android.com/jetpack/androidx/releases/work#2.5.0">release notes</a>.</p><h3>What you can do to improve WorkManager</h3><h4><strong>Contribute to WorkManager through GitHub 👩‍💻</strong></h4><p>WorkManager, as well as several other Jetpack libraries, can accept contributions via GitHub.</p><p><a href="https://medium.com/u/d42e45d76c8a">Alan Viverette</a> wrote a <a href="https://medium.com/androiddevelopers/introducing-jetpack-on-github-c2c9f12e62a9">comprehensive blog post</a> about the entire process.</p><h4><strong>Let us know when something goes wrong 📝</strong></h4><p>Most of the bugs fixed in the 2.5.0 release came in through input from the <a href="https://issuetracker.google.com/issues?q=componentid:409906">public issue tracker</a>.</p><p>The best way to create an issue we can fix is by <a href="https://issuetracker.google.com/issues/new?component=409906">creating an issue</a> we can reproduce. To help us reproduce an issue, we recommend that you use the <a href="https://github.com/android/architecture-components-samples/tree/main/WorkManagerSample">WorkManager sample</a> or provide your own sample code with instructions in the issue description.</p><p>Now is the right time to get to work and manage updating that library version in your app.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=701b668cd064" width="1" height="1" alt=""><hr><p><a href="https://medium.com/androiddevelopers/workmanager-2-5-0-stable-released-701b668cd064">WorkManager 2.5.0 stable released</a> was originally published in <a href="https://medium.com/androiddevelopers">Android Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>