simpleperf/systrace/atrace
adb wait-for-device root
adb wait-for-device remount
adb push simpleperf /data/local/tmp/
adb shell "chmod 777 /data/local/tmp/simpleperf"
adb shell "/data/local/tmp/simpleperf record -p 1226--duration 15 -f 10000 --call-graph fp -o /data/local/tmp/perf.data"
adb pull /data/local/tmp/perf.data .
simpleperf 使用https://profiler.firefox.com/ 打开
system/extras/simpleperf
adb shell "simpleperf record -p 1226 --duration 60 -f 10000 --call-graph fp -o /data/local/tmp/perf.data"
adb shell "simpleperf record --app android.video.cts --duration 4 -f 10000 -g -o /data/local/tmp/perf.data"
//下载simpleperf 在scripts路径下执行
adb pull /data/local/tmp/perf.data .
./gecko_profile_generator.py -i ./perf.data | gzip > perf.json.gz
adb shell "echo 1 > /sys/kernel/tracing/events/raw_syscalls/enable"
adb shell atrace --async_start -b 20480 video sched freq power
adb shell atrace --async_stop -b 20480 video sched freq power > atrace.html
systrace 使用https://ui.perfetto.dev/ 打开
adb shell rm -rf /data/misc/perfetto-traces/trace.perfetto-trace && adb push "D:\vinter\7.tools\trace\config.pbtx.txt" /data/local/tmp/config.pbtx && adb shell "cat /data/local/tmp/config.pbtx | perfetto --txt -c - -o /data/misc/perfetto-traces/trace.perfetto-trace --detach=perf_debug"
adb root && adb shell "perfetto --attach=perf_debug --stop" && adb pull /data/misc/perfetto-traces/trace.perfetto-trace ./../log
config.pbtx.txt
buffers: {
size_kb: 707200
fill_policy: RING_BUFFER
}
buffers: {
size_kb: 707200
fill_policy: RING_BUFFER
}
data_sources: {
config {
name: "linux.process_stats"
target_buffer: 1
process_stats_config {
scan_all_processes_on_start: true
proc_stats_poll_ms: 1000
}
}
}
data_sources: {
config {
name: "android.log"
android_log_config {
}
}
}
data_sources: {
config {
name: "android.surfaceflinger.frametimeline"
}
}
data_sources: {
config {
name: "linux.sys_stats"
sys_stats_config {
meminfo_period_ms: 2500
vmstat_period_ms: 1000
stat_period_ms: 0
stat_counters: STAT_CPU_TIMES
stat_counters: STAT_FORK_COUNT
}
}
}
data_sources: {
config {
name: "android.heapprofd"
target_buffer: 0
heapprofd_config {
sampling_interval_bytes: 4096
shmem_size_bytes: 8388608
block_client: true
}
}
}
data_sources: {
config {
name: "android.java_hprof"
target_buffer: 0
java_hprof_config {
}
}
}
data_sources: {
config {
name: "linux.ftrace"
ftrace_config {
ftrace_events: "sched/sched_switch"
ftrace_events: "power/suspend_resume"
ftrace_events: "sched/sched_wakeup"
ftrace_events: "sched/sched_wakeup_new"
ftrace_events: "sched/sched_waking"
ftrace_events: "power/cpu_frequency"
ftrace_events: "power/gpu_frequency"
ftrace_events: "power/cpu_idle"
ftrace_events: "sched/sched_process_exit"
ftrace_events: "sched/sched_process_free"
ftrace_events: "task/task_newtask"
ftrace_events: "task/task_rename"
ftrace_events: "lowmemorykiller/lowmemory_kill"
ftrace_events: "oom/oom_score_adj_update"
ftrace_events: "ftrace/print"
ftrace_events: "sched/sched_blocked_reason"
buffer_size_kb: 2048
drain_period_ms: 250
symbolize_ksyms: true
atrace_categories: "input"
atrace_categories: "gfx"
atrace_categories: "view"
atrace_categories: "webview"
atrace_categories: "camera"
atrace_categories: "dalvik"
atrace_categories: "power"
atrace_categories: "wm"
atrace_categories: "am"
atrace_categories: "sched"
atrace_categories: "freq"
atrace_apps: "*"
}
}
}
duration_ms: 600000
flush_period_ms: 30000
incremental_state_config {
clear_period_ms: 5000
}
write_into_file: true