360搜索的网站收录入口,大淘客怎样做网站,设计logo的方法,浙江高端建设网站序言
最近在研究性能问题需要抓取trace文件。于是写了个脚本
使用
双击运行批处理文件#xff0c;可以开始记录trace。而且以当前文件夹下面的。config.pbtx 作为配置文件。 #xff08;pbtx就是一个json文件。配置了需要抓取那些参数#xff0c;可以通过https://ui.per…序言
最近在研究性能问题需要抓取trace文件。于是写了个脚本
使用
双击运行批处理文件可以开始记录trace。而且以当前文件夹下面的。config.pbtx 作为配置文件。 pbtx就是一个json文件。配置了需要抓取那些参数可以通过https://ui.perfetto.dev/中的Record new trace 左侧的菜单在右侧设置最近要记录什么内容。来生成配置文件。可以参考 Android Perfetto 系列 2Perfetto Trace 抓取 最后的文件在Cmdline instructions菜单中显示。 右边下方的内容拷贝到。当前目录并命名为config.pbtx 记得把配置中的时间去除这样可以一直记录。 在当前文件夹下新建批处理
echo off
chcp 65001 nulecho off
setlocal enabledelayedexpansion:: 获取当前目录
echo 当前目录: %cd%:: 使用 PowerShell 获取时间戳
for /f delims %%a in (powershell.exe -Command Get-Date -Format yyyyMMdd_HHmmss) do set timestamp%%a
echo 时间戳: %timestamp%:: 删除旧 trace 文件
adb shell rm -rf /data/misc/perfetto-traces/trace.perfetto
timeout /t 1 nul:: 推送配置文件
adb push config.pbtx /data/misc/perfetto-configs/config.pbtx
timeout /t 1 nul:: 开始录制
echo 开始记录 trace请按 CtrlC 结束录制...
adb shell -tt perfetto --txt -c /data/misc/perfetto-configs/config.pbtx -o /data/misc/perfetto-traces/trace.perfetto:: 导出 trace 到当前目录
adb pull /data/misc/perfetto-traces/trace.perfetto .\trace_%timestamp%.perfettoif exist trace_%timestamp%.perfetto (echo ✅ 文件已成功导出到当前目录echo trace_%timestamp%.perfettoecho.echo 正在打开 Perfetto 官方网站请稍后手动上传 trace 文件。echo 1. 浏览器将自动打开 Perfetto UI。echo 2. 点击左上角 ^ Open trace file^ 按钮。echo 3. 选择刚刚保存的 trace_%timestamp%.perfetto 文件。echo.:: 打开默认浏览器访问 Perfetto UIstart https://ui.perfetto.dev/) else (echo ❌ 文件未找到请检查设备路径或配置。
)pause双击bat运行要结束录制的话只需要按下 CtrlC 就可以了。 最后文件会自动保存到当前文件夹下以时间命名。 最后还会自动打开分析网站。只需要把日志文件拖入浏览器就可以打开。
附带配置
这是我的配置文件可以记录logcat
buffers {size_kb: 65536fill_policy: DISCARD
}
buffers {size_kb: 4096fill_policy: DISCARD
}
data_sources {config {name: linux.ftraceftrace_config {ftrace_events: sched/sched_process_exitftrace_events: sched/sched_process_freeftrace_events: task/task_newtaskftrace_events: task/task_renameftrace_events: binder/*ftrace_events: block/*ftrace_events: clk/*ftrace_events: devfreq/*ftrace_events: ext4/*ftrace_events: f2fs/*ftrace_events: i2c/*ftrace_events: irq/*ftrace_events: kmem/*ftrace_events: memory_bus/*ftrace_events: mmc/*ftrace_events: oom/*ftrace_events: power/*ftrace_events: regulator/*ftrace_events: sched/*ftrace_events: sync/*ftrace_events: task/*ftrace_events: vmscan/*ftrace_events: fastrpc/*ftrace_events: sched/sched_switchftrace_events: power/suspend_resumeftrace_events: sched/sched_blocked_reasonftrace_events: sched/sched_wakeupftrace_events: sched/sched_wakeup_newftrace_events: sched/sched_wakingftrace_events: sched/sched_process_exitftrace_events: sched/sched_process_freeftrace_events: task/task_newtaskftrace_events: task/task_renameftrace_events: power/cpu_frequencyftrace_events: power/cpu_idleftrace_events: power/suspend_resumeftrace_events: raw_syscalls/sys_enterftrace_events: raw_syscalls/sys_exitftrace_events: power/gpu_frequencyftrace_events: gpu_mem/gpu_mem_totalftrace_events: power/gpu_work_periodftrace_events: ftrace/printatrace_categories: adbatrace_categories: aidlatrace_categories: amatrace_categories: audioatrace_categories: binder_driveratrace_categories: binder_lockatrace_categories: bionicatrace_categories: cameraatrace_categories: dalvikatrace_categories: databaseatrace_categories: gfxatrace_categories: halatrace_categories: inputatrace_categories: networkatrace_categories: nnapiatrace_categories: pmatrace_categories: poweratrace_categories: resatrace_categories: rroatrace_categories: rsatrace_categories: smatrace_categories: ssatrace_categories: vibratoratrace_categories: videoatrace_categories: viewatrace_categories: webviewatrace_categories: wmsymbolize_ksyms: truedisable_generic_events: true}}
}
data_sources {config {name: linux.process_statsprocess_stats_config {scan_all_processes_on_start: true}}
}
data_sources {config {name: linux.sys_statssys_stats_config {meminfo_period_ms: 5000stat_period_ms: 250stat_counters: STAT_CPU_TIMESstat_counters: STAT_FORK_COUNTcpufreq_period_ms: 250}}
}
data_sources {config {name: android.gpu.memory}
}
data_sources {config {name: android.java_hprofjava_hprof_config {}}
}
data_sources {config {name: android.logandroid_log_config {log_ids: LID_CRASHlog_ids: LID_DEFAULTlog_ids: LID_EVENTSlog_ids: LID_KERNELlog_ids: LID_RADIOlog_ids: LID_SECURITYlog_ids: LID_STATSlog_ids: LID_SYSTEM}}
}
data_sources {config {name: android.surfaceflinger.frametimeline}
}
data_sources {config {name: android.game_interventions}
}
data_sources {config {name: android.network_packetsnetwork_packet_trace_config {poll_ms: 1000}}
}
data_sources {config {name: android.packages_list}
}
data_sources {config {name: android.statsdstatsd_tracing_config {push_atom_id: ATOM_PROCESS_STATE_CHANGEDpush_atom_id: ATOM_BLE_SCAN_RESULT_RECEIVEDpush_atom_id: ATOM_SENSOR_STATE_CHANGEDpush_atom_id: ATOM_GPS_SCAN_STATE_CHANGED}}
}
data_sources {config {name: linux.perfperf_event_config {timebase {frequency: 100timestamp_clock: PERF_CLOCK_MONOTONIC}callstack_sampling {}}}
}