Trace

本文详细介绍了如何使用Simpleperf进行性能记录,Systrace和Atrace进行系统级追踪,以及配置Perfetto数据源以收集各种系统和应用数据。还涉及了ADB命令和Gecko_profile_generator的使用过程。
摘要由CSDN通过智能技术生成

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值