- Wakelock analysis
- Kernel trace analysis
- Other command line tools
Wakelock analysis
默认情况下,Android不会记录指定应用的用户空间下wakelock transitions的时间戳。如果想要让 Historian 在timeline展示每个 individual wakelock 的详细信息,就需要在开始操作试验之前通过下面的命令开启 full wakelock reporting。
adb shell dumpsys batterystats --enable full-wake-history
需要注意的是,一旦开启 full wakelock reporting,电池历史日志记录将在几小时后溢出。使用此选项可进行短期测试(3-4小时)。
Kernel trace analysis
要生成记录内核唤醒源和内核唤醒锁活动的跟踪文件,
首先开启 kernel trace logging:
$ adb root
$ adb shell
Set the events to trace.
$ echo "power:wakeup_source_activate" >> /d/tracing/set_event
$ echo "power:wakeup_source_deactivate" >> /d/tracing/set_event
The default trace size for most devices is 1MB, which is relatively low and might cause the logs to overflow.
8MB to 10MB should be a decent size for 5-6 hours of logging.
$ echo 8192 > /d/tracing/buffer_size_kb
$ echo 1 > /d/tracing/tracing_on
使用设备跑测试场景
完成后导出日志
$ echo 0 > /d/tracing/tracing_on
$ adb pull /d/tracing/trace <some path>
##### Take a bug report at this time.
$ adb bugreport > bugreport.txt
Other command line tools
System stats
$ go run cmd/checkin-parse/local_checkin_parse.go --input=bugreport.txt
Timeline analysis
$ go run cmd/history-parse/local_history_parse.go --summary=totalTime --input=bugreport.txt
Diff two bug reports
$ go run cmd/checkin-delta/local_checkin_delta.go --input=bugreport_1.txt,bugreport_2.txt