Skip to content
TheChatArchiveThe Chat Archive
gpt-4.1-mini-2025-04-14· OpenAIAi2 WildChat-4.8M (AI2)

Android performance with ADB

  1. User

    Android performance with ADB

  2. Assistant

    Sure! When you mention Android performance with ADB, you might be interested in how to use ADB (Android Debug Bridge) to monitor, analyze, or improve the performance of an Android device or app. Below is an overview of how ADB can help with performance-related tasks and some practical commands you can use.


    What is ADB?

    ADB is a versatile command-line tool that lets you communicate with an Android device. It allows you to perform many device actions, such as installing apps, copying files, running shell commands, and debugging.


    Using ADB for Android Performance Analysis

    1. Monitor CPU Usage

    You can use adb shell top or adb shell dumpsys cpuinfo to check real-time CPU usage of apps/processes:

    adb shell top -m 10 -s cpu
    
    • -m 10: shows top 10 processes
    • -s cpu: sorts by CPU usage

    Or:

    adb shell dumpsys cpuinfo
    

    This provides a snapshot of CPU usage by all running processes.


    2. Check Memory Usage

    To see memory usage breakdown per app/process:

    adb shell dumpsys meminfo <package_name>
    

    Example:

    adb shell dumpsys meminfo com.example.app
    

    This will give detailed info about PSS, Heap sizes, Native and Dalvik memory usage.


    3. Profile GPU Rendering

    To profile GPU rendering of your app to detect performance bottlenecks:

    adb shell setprop debug.hwui.profile visual_bars
    

    Then, open your app; you’ll see GPU rendering overlaid as bars on the screen.

    To disable:

    adb shell setprop debug.hwui.profile null
    

    4. Trace System Processes

    You can capture system-wide performance traces using atrace:

    adb shell atrace --app=com.example.app -b 4096 -t 10 gfx input view wm
    
    • -b 4096: buffer size
    • -t 10: duration in seconds
    • Categories like gfx (graphics), input, view, wm (window manager)

    Retrieve trace:

    adb pull /data/local/traces/trace.html
    

    You can then analyze traces in Chrome’s tracing UI.


    5. Check Battery and Power Consumption

    To inspect battery stats, which are relevant for performance:

    adb shell dumpsys batterystats
    

    To reset stats:

    adb shell dumpsys batterystats --reset
    

    6. Network Performance

    Use ADB to track network stats:

    adb shell dumpsys netstats
    adb shell iftop
    

    You can also use tcpdump on rooted devices to capture network packets.


    7. Other Useful Commands

    • Logcat: Useful to correlate performance issues with logs
    adb logcat
    
    • Force Garbage Collection (GC) in the app:
    adb shell am send-trim-memory com.example.app RUNNING_CRITICAL
    
    • Kill and restart the app for fresh performance tests:
    adb shell am force-stop com.example.app
    adb shell am start -n com.example.app/.MainActivity
    

    Summary

    ADB provides many commands that help analyze Android device and app performance — CPU, memory, GPU, network, battery, and more. These tools are useful both during development and while debugging issues on physical devices.

    If you want, I can help you with specific scripts or walk you through more advanced profiling setups. Just let me know!

  3. User

    Translate Indonesia

  4. Assistant

    Tentu! Berikut adalah terjemahan penjelasan tentang kinerja Android dengan ADB dalam bahasa Indonesia:


    Apa itu ADB?

    ADB (Android Debug Bridge) adalah alat baris perintah yang memungkinkan Anda berkomunikasi dengan perangkat Android. Anda dapat melakukan berbagai tindakan, seperti memasang aplikasi, menyalin file, menjalankan perintah shell, dan melakukan debugging.


    Menggunakan ADB untuk Analisis Kinerja Android

    1. Memantau Penggunaan CPU

    Gunakan perintah berikut untuk melihat penggunaan CPU secara real-time:

    adb shell top -m 10 -s cpu
    

    atau

    adb shell dumpsys cpuinfo
    

    2. Memeriksa Penggunaan Memori

    Periksa rincian penggunaan memori aplikasi dengan:

    adb shell dumpsys meminfo <nama_paket_aplikasi>
    

    Contoh:

    adb shell dumpsys meminfo com.example.app
    

    3. Profil GPU Rendering

    Untuk menganalisis kinerja GPU, gunakan:

    adb shell setprop debug.hwui.profile visual_bars
    

    Untuk mematikan fitur ini:

    adb shell setprop debug.hwui.profile null
    

    4. Melacak Proses Sistem

    Rekam jejak performa dengan:

    adb shell atrace --app=com.example.app -b 4096 -t 10 gfx input view wm
    

    Ambil file hasil rekaman dengan:

    adb pull /data/local/traces/trace.html
    

    5. Memeriksa Baterai dan Konsumsi Daya

    Lihat statistik baterai:

    adb shell dumpsys batterystats
    

    Reset statistik baterai:

    adb shell dumpsys batterystats --reset
    

    6. Kinerja Jaringan

    Lihat statistik jaringan dengan:

    adb shell dumpsys netstats
    

    7. Perintah Lain yang Berguna

    • Logcat untuk melihat log perangkat:
    adb logcat
    
    • Memaksa Garbage Collection (GC) pada aplikasi:
    adb shell am send-trim-memory com.example.app RUNNING_CRITICAL
    
    • Menghentikan dan menjalankan ulang aplikasi:
    adb shell am force-stop com.example.app
    adb shell am start -n com.example.app/.MainActivity
    

    Jika Anda ingin saya jelaskan lebih detail atau membantu dengan contoh tertentu, silakan beri tahu!

  5. User

    CMD power ADB command?

  6. Assistant

    If you’re asking about power-related ADB commands that can be run from the CMD (Command Prompt) on your PC to interact with an Android device, here are some common commands related to power management and controlling the device’s power state:


    Common Power-Related ADB Commands

    1. Turn screen on / off

    • Turn screen off:
    adb shell input keyevent 26
    

    (Keyevent 26 corresponds to the POWER button; toggles screen state)

    • Turn screen on:

    Sometimes just sending this key event turns the screen on if it was off. Otherwise, you can wake the device and unlock the screen:

    adb shell input keyevent 224    # WAKEUP
    adb shell input keyevent 82     # MENU (to unlock)
    

    2. Reboot device

    • Simple reboot:
    adb reboot
    
    • Reboot to bootloader:
    adb reboot bootloader
    
    • Reboot to recovery mode:
    adb reboot recovery
    

    3. Put device to sleep (doze mode)

    adb shell dumpsys deviceidle force-idle
    

    This forces the device into idle (doze) mode.

    4. Wake device from sleep

    adb shell dumpsys deviceidle unforce
    adb shell input keyevent 224   # WAKEUP
    

    5. Check battery state and info

    adb shell dumpsys battery
    

    Shows current battery status (level, charging state, etc).

    6. Set battery level (emulator only)

    adb shell dumpsys battery set level <value> 
    

    Example to set battery level to 50%:

    adb shell dumpsys battery set level 50
    

    To reset battery to normal:

    adb shell dumpsys battery reset
    

    Notes

    • Make sure ADB is installed and your device is connected and authorized.
    • Use adb devices to confirm connection.
    • Running CMD commands means typing these commands into Windows Command Prompt (or Terminal on Mac/Linux).
    • Some commands may require the device to be rooted for full access.

    If you want specific power management commands or automation scripts via CMD + ADB, just let me know!