# Profiling and Optimization Techniques for Jetpack Compose Apps

DevFeed: [Profiling and Optimization Techniques for Jetpack Compose Apps](<https://devfeed.tech/articles/optimize-or-die-profiling-and-optimization-in-jetpack-compose-23910.md>)

Original publisher: [Read original article](<https://medium.com/icerock/optimize-or-die-profiling-and-optimization-in-jetpack-compose-a165c8897b3f?source=rss----b74ae24564e---4>)

Author: IceRock Development

Published: 2023-04-28T03:14:45Z

Content type: tutorial

Language: en

Sources: [IceRock Development - Medium](<https://devfeed.tech/sources/icerock-development-medium.md>)

Topics: [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [Optimization](<https://devfeed.tech/topics/optimization.md>), [Android Studio](<https://devfeed.tech/topics/android-studio.md>), [Android](<https://devfeed.tech/topics/android.md>), [cpu](<https://devfeed.tech/topics/cpu.md>), [GPU](<https://devfeed.tech/topics/gpu.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [android-app-development](<https://devfeed.tech/tags/android-app-development.md>), [android-studio](<https://devfeed.tech/tags/android-studio.md>), [compose-compiler](<https://devfeed.tech/tags/compose-compiler.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [emulator](<https://devfeed.tech/tags/emulator.md>), [gpu](<https://devfeed.tech/tags/gpu.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [mobile-app-development](<https://devfeed.tech/tags/mobile-app-development.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [performance](<https://devfeed.tech/tags/performance.md>), [profiling](<https://devfeed.tech/tags/profiling.md>), [recomposition](<https://devfeed.tech/tags/recomposition.md>)

## AI overview

This tutorial uses the Campus student schedule app to explain profiling and optimization techniques for Jetpack Compose. It covers excessive recompositions, Compose Compiler Metrics, CPU and GPU profiling, and Android Studio's Recomposition Counts tool.

## Source excerpt

Your brand-new app gets bombarded with user complaints on Google Play about it hanging or slowing down? Follow the tips in this article to fix it. Hello! My name is Sergey Panov, and I am a mobile developer at IceRock. Today, I will be using our Campus app as an example to demonstrate profiling and optimization techniques for Jetpack Compose. Campus is an app that allows students to view their class schedule. Its main feature is the schedule screen consisting of two pagers for weeks and days. When users tried to swipe them, it caused the app to hang, but we managed to fix it. Here are the topics discussed in the article: Recomposition Counts. Pinpointing Excessive Recompositions. Compose Compiler Metrics. Identifying the Root Causes of Excessive Recompositions. CPU Profiling. Finding "Hot" Methods and Freeing up the CPU. GPU Profiling. Learning Which Components Take a Long Time to Draw. More Tips on Fixing Bugs Identified with Profiling Tools. Recomposition Counts. Pinpointing Excessive Recompositions Issue. The first concept we need to highlight is that of recomposition. Rendering a screen in Compose consists of traversing the graph of composable functions. If a graph node changes its state (i.e. arguments of a composable method, values of MutableState or animations change), the subgraph is updated, that is, the functions are called again. Such an update is called a recomposition. Recompositions are fast and should not present any issues, but frequent recompositions can cause an app to slow down. This is a distinctive feature and a pitfall of Compose. After all, a developer can make some mistakes leading to excessive recompositions, for instance, recreate an object instead of reusing it. This results in unnecessary computations and performance issues. Solution. In large projects, these mistakes might be tricky to detect by the unaided eye, so Android Studio provides our eyes with an aid -- a tool called Recomposition Counts. It can be enabled in Layout Inspector to