Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android 性能優化 五 性能分析工具dumpsys的使用

Android 性能優化 五 性能分析工具dumpsys的使用

編輯:關於Android編程


Android提供的dumpsys工具可以用於查看感興趣的系統服務信息與狀態,手機連接電腦後可以直接命令行執行adb shell dumpsys 查看所有支持的Service但是這樣輸出的太多,可以通過dumpsys | grep "DUMP OF SERVICE" 僅顯示主要的Service的信息

一、列出dumpsys所有支持命令

> adb shell
$ dumpsys | grep "DUMP OF SERVICE"

以下是在我個人三星S3手機上的輸出信息
C:\Windows\System32>adb shell
shell@m:/ $ dumpsys | grep "DUMP OF SERVICE"
dumpsys | grep "DUMP OF SERVICE"
DUMP OF SERVICE AtCmdFwd:
DUMP OF SERVICE CustomFrequencyManagerService:
DUMP OF SERVICE DirEncryptService:
DUMP OF SERVICE Exynos.HWCService:
DUMP OF SERVICE Exynos.IPService:
DUMP OF SERVICE FMPlayer:
DUMP OF SERVICE LEDService:
DUMP OF SERVICE SecTVOutService:
DUMP OF SERVICE SurfaceFlinger:
DUMP OF SERVICE TvoutService_C:
DUMP OF SERVICE accessibility:
DUMP OF SERVICE account:
DUMP OF SERVICE activity:
DUMP OF SERVICE alarm:
DUMP OF SERVICE android.security.keystore:
DUMP OF SERVICE application_policy:
DUMP OF SERVICE appops:
DUMP OF SERVICE appwidget:
DUMP OF SERVICE audio:
DUMP OF SERVICE backup:
DUMP OF SERVICE battery:
DUMP OF SERVICE batteryinfo:
DUMP OF SERVICE bluetooth_manager:
DUMP OF SERVICE bluetooth_secure_mode_manager:
DUMP OF SERVICE clipboard:
DUMP OF SERVICE clipboardEx:
DUMP OF SERVICE commontime_management:
DUMP OF SERVICE connectivity:
DUMP OF SERVICE container_service:
DUMP OF SERVICE content:
DUMP OF SERVICE country_detector:
DUMP OF SERVICE cpuinfo:
DUMP OF SERVICE dbinfo:
DUMP OF SERVICE device_policy:
DUMP OF SERVICE devicestoragemonitor:
DUMP OF SERVICE diskstats:
DUMP OF SERVICE display:
DUMP OF SERVICE dreams:
DUMP OF SERVICE drm.drmManager:
DUMP OF SERVICE dropbox:
DUMP OF SERVICE edmnativehelper:
DUMP OF SERVICE enterprise_license_policy:
DUMP OF SERVICE enterprise_policy:
DUMP OF SERVICE entropy:
DUMP OF SERVICE gfxinfo:
DUMP OF SERVICE hardware:
DUMP OF SERVICE harmony_eas_service:
DUMP OF SERVICE input:
DUMP OF SERVICE input_method:
DUMP OF SERVICE iphonesubinfo:
DUMP OF SERVICE isms:
DUMP OF SERVICE license_log_service:
DUMP OF SERVICE location:
DUMP OF SERVICE lock_settings:
DUMP OF SERVICE log_manager_service:
DUMP OF SERVICE mdm.remotedesktop:
DUMP OF SERVICE media.audio_flinger:
DUMP OF SERVICE media.audio_policy:
DUMP OF SERVICE media.camera:
DUMP OF SERVICE media.player:
DUMP OF SERVICE meminfo:
DUMP OF SERVICE motion_recognition:
DUMP OF SERVICE mount:
DUMP OF SERVICE multiwindow:
DUMP OF SERVICE netpolicy:
DUMP OF SERVICE netstats:
DUMP OF SERVICE network_management:
DUMP OF SERVICE nfc:
DUMP OF SERVICE nfccontroller:
DUMP OF SERVICE notification:
DUMP OF SERVICE package:
DUMP OF SERVICE permission:
DUMP OF SERVICE phone:
DUMP OF SERVICE phone_restriction_policy:
DUMP OF SERVICE phoneext:
DUMP OF SERVICE power:
DUMP OF SERVICE remoteinjection:
DUMP OF SERVICE samplingprofiler:
DUMP OF SERVICE samsung.smartfaceservice:
DUMP OF SERVICE scheduling_policy:
DUMP OF SERVICE search:
DUMP OF SERVICE sec_analytics:
DUMP OF SERVICE secontroller:
DUMP OF SERVICE sensorservice:
DUMP OF SERVICE serial:
DUMP OF SERVICE servicediscovery:
DUMP OF SERVICE simphonebook:
DUMP OF SERVICE sip:
DUMP OF SERVICE statusbar:
DUMP OF SERVICE telephony.registry:
DUMP OF SERVICE textservices:
DUMP OF SERVICE tvoutservice:
DUMP OF SERVICE uimode:
DUMP OF SERVICE updatelock:
DUMP OF SERVICE usagestats:
DUMP OF SERVICE usb:
DUMP OF SERVICE user:
DUMP OF SERVICE vibrator:
DUMP OF SERVICE voip:
DUMP OF SERVICE wallpaper:
DUMP OF SERVICE wfd:
DUMP OF SERVICE wifi:
DUMP OF SERVICE wifi_policy:
DUMP OF SERVICE wifip2p:
DUMP OF SERVICE window:

二、具體命令如何查看幫助

從上面可以看出Service非常多,“DUMP OF SERVICE”關鍵字後面的單詞都可以直接通過 dumpsys + 單詞 查看相關信息,具體每一個如何使用有一種通用的查看幫助的辦法。
查看每一個命令的使用幫助,以下以meminfo 為例演示:
shell@m:/ $ dumpsys meminfo -h
dumpsys meminfo -h
meminfo dump options: [-a] [--oom] [process]
  -a: include all available information for each process.
  --oom: only show processes organized by oom adj.
If [process] is specified it can be the name or
pid of a specific process to dump.

三、一些關鍵命令解釋


名字 功能 account 顯示accounts信息 activity 顯示所有的activities的信息 cpuinfo 顯示CPU信息 window 顯示鍵盤,窗口和它們的關系 wifi 顯示wifi信息 batteryinfo $package_name 電量信息及CPU 使用時長 package packagename 獲取安裝包信息 usagestats 每個界面啟動的時間 statusbar 顯示狀態欄相關的信息 meminfo 內存信息(meminfo $package_name or $pid 使用程序的包名或者進程id顯示內存信息) diskstats 磁盤相關信息 battery 電池信息 alarm 顯示Alarm信息
activity - 使用adb shell dumpsys檢測Android的Activity任務棧 window - 通過adb shell dumpsys命令獲取當前應用的component
statusbar - 找出廣告通知屬於哪個應用 dumpsys statusbar | grep notification=Notification



四、參考資料

Dumpsys (官方文檔)
How to discover memory usage of my application in Android
android中dumpsys函數介紹與使用 (代碼分析)



更多優化相關的文章詳見:《Android 基礎學習文章匯總》 第三部分 性能優化



  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved