自学内容网 自学内容网

trace配置及命令文件

  1. 配置文件:config.txt
buffers: {
    size_kb: 522240
    fill_policy: RING_BUFFER
}

buffers: {
    size_kb: 2048
    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: "linux.sys_stats"
        sys_stats_config {
            stat_period_ms: 1000
            stat_counters: STAT_CPU_TIMES
            stat_counters: STAT_FORK_COUNT
        }
    }
}

data_sources: {
    config {
        name: "linux.ftrace"
        ftrace_config {
            ftrace_events: "block/*" 
            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/cpu_idle" 
            ftrace_events: "power/gpu_frequency" 
            ftrace_events: "sched/sched_process_exit" 
            ftrace_events: "sched/sched_process_free" 
            ftrace_events: "task/task_newtask" 
            ftrace_events: "task/task_rename" 
            ftrace_events: "ftrace/print"
            atrace_categories: "am"
            atrace_categories: "adb"
            atrace_categories: "aidl"
            atrace_categories: "dalvik"
            atrace_categories: "audio"
            atrace_categories: "binder_lock"
            atrace_categories: "binder_driver"
            atrace_categories: "bionic"
            atrace_categories: "camera"
            atrace_categories: "database"
            atrace_categories: "gfx"
            atrace_categories: "hal"
            atrace_categories: "input"
            atrace_categories: "network"
            atrace_categories: "nnapi"
            atrace_categories: "pm"
            atrace_categories: "power"
            atrace_categories: "res"
            atrace_categories: "rro"
            atrace_categories: "sm"
            atrace_categories: "vibrator"
            atrace_categories: "video"
            atrace_categories: "view"
            atrace_categories: "webview"
            atrace_categories: "wm"
            atrace_apps: "*"
        }
    }
}
duration_ms: 15000

2. 抓trace的命令文件: perfetto.sh

备注说明:生成一个.html结尾的,保存在“/home/xadz1307/trace/”的文件。

#!/bin/bash
date_time=$(date +"%Y_%m%d_%H%M")
echo $date_time
product_name=`adb shell getprop ro.product.name`
FILE_NAME=$product_name"_"$date_time
echo $FILE_NAME
CURRENT_PATH=$(cd $(dirname $0); pwd)
echo $CURRENT_PATH
TRACE_PATH=/home/xadz1307/trace/

adb push config.txt /data/misc/perfetto-traces/config.txt

adb shell "perfetto -c /data/misc/perfetto-traces/config.txt --txt -o /data/misc/perfetto-traces/$FILE_NAME.html"

adb pull /data/misc/perfetto-traces/$FILE_NAME.html $TRACE_PATH

3. 打开trace文件:

google浏览器-打开--  --> open trace file


原文地址:https://blog.csdn.net/qq_31123505/article/details/136562288

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!