# Profiling and Optimizing Jetpack Compose Apps with Recomposition, CPU, and GPU Analysis

DevFeed: [Profiling and Optimizing Jetpack Compose Apps with Recomposition, CPU, and GPU Analysis](<https://devfeed.tech/articles/optimize-or-die-profiling-and-optimization-in-jetpack-compose-24587.md>)

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

Author: IceRock Development

Published: 2023-01-25T06:55:43Z

Content type: tutorial

Language: en

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

Topics: [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [Compose](<https://devfeed.tech/topics/compose.md>), [Optimization](<https://devfeed.tech/topics/optimization.md>), [Android Studio](<https://devfeed.tech/topics/android-studio.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [cpu](<https://devfeed.tech/topics/cpu.md>), [GPU](<https://devfeed.tech/topics/gpu.md>), [Mobile](<https://devfeed.tech/topics/mobile.md>), [Emulator](<https://devfeed.tech/topics/emulator.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](<https://devfeed.tech/tags/compose.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 demonstrates profiling and optimization techniques for Jetpack Compose using the Campus student-schedule app. It explains how to detect excessive recompositions with Recomposition Counts and Compose Compiler Metrics, then use CPU and GPU profiling to identify performance problems and slow-to-draw components.

## 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