端到端鸿蒙
应用性能分析
End-to-end
HarmonyOS app
performance analysis
宿主 Agent + Diting 现在可以完成「改代码 → 构建 → 签名 → 安装 → 启动 → 抓 Trace → 分析」的完整闭环:Agent 负责判断和决策,Diting 在设备上执行并输出带证据的报告。 Host agent + Diting now completes the full loop — edit code → build → sign → install → launch → capture a trace → analyze. The agent decides; Diting executes on-device and returns an evidence-backed report.
从代码或 Trace 开始。Start from code or a trace.
可以从一次代码改动开始:Agent 修改工程,Diting 构建、签名、安装并启动应用,再抓取 Trace;也可以直接分析已有 HTrace。两条路径进入同一套分析、校验和报告流程。 Start from a code change: the agent edits the project, then Diting builds, signs, installs, and launches the app before capturing a trace. Or bring an existing HTrace. Both paths lead into the same analysis, validation, and reporting pipeline.
从代码改动到 Trace。From code change to trace.
需要 --enable-device。Agent 可以修改工程,调用 build_app、sign_app 和 install_app 完成构建、签名与安装;package_app 可生成 App Pack。随后启动应用并在目标交互期间抓 Trace。
Requires --enable-device. The agent edits the project, uses build_app, sign_app, and install_app to build, sign, and install it, and can use package_app for an App Pack before launching the app and capturing a trace around the target interaction.
build_appsign_appinstall_appcapture_trace
这些工具默认关闭,需要在启动时加 --enable-device;install_app 和 act 会真实修改设备。
These tools are opt-in via --enable-device. install_app and act really change the device.
已经有一份 HTrace,通过 Agent 会话分析。Already have an HTrace? Analyse it through an agent session.
宿主 Agent 调用 open_trace 转换并打开 Trace,再调用 begin_analysis 声明场景、现象和边界。首次转换结果会写入内容寻址缓存。 The host agent calls open_trace to convert and open the trace, then begin_analysis to declare the scenario, symptom, and boundary. The conversion is cached by content hash.
open_trace("case.htrace")
begin_analysis(
scenario_type="frame-jank",
scenario="scroll list",
symptom="repeated dropped frames",
refresh_rate_hz=120
)
四类性能场景。Four performance scenarios.
同一个“慢”字,可能是启动、首帧反馈、业务完成或一簇掉帧。DitingAgent 先固定时间边界,再选择对应的取证工具。 “Slow” can mean launch, first feedback, business completion, or a cluster of dropped frames. DitingAgent fixes the interval first, then selects the matching evidence tools.
冷启动Cold start
进程创建 → 应用定义的启动完成,或稳定的首页帧。Process creation → app-defined startup end, or a stable home frame.
inspect_cold_start_*
响应时延Response latency
有效输入 → 第一帧包含有效视觉反馈。Valid input → the first frame with effective visual feedback.
inspect_completion_latency_candidates
完成时延Completion latency
输入 → 有效响应 → 业务完成,拆成三段测量。Input → effective response → business completion, measured in three parts.
inspect_completion_latency_phases
帧率与卡顿Frame jank
按实际刷新率计算帧预算,定位慢帧簇和 deadline miss。Derive the frame budget from the actual refresh rate, then locate slow-frame clusters and deadline misses.
inspect_frame_jank
工具能力Tool capabilities
默认 37 个工具,开启设备与构建工具后 55 个。这里按主要任务分组。 37 tools by default, 55 with device and build tools enabled. They are grouped by task.
Trace 取证Trace inspection
概览、进程/线程、CPU/内存/IO、受限 SQL、四类场景、单帧下钻、线程执行和 Perf Profile。Overview, processes and threads, CPU/memory/IO, restricted SQL, four scenarios, frame drill-down, thread execution, and Perf profiles.
get_trace_overview · query_trace_sql · inspect_*
设备、构建与环境Device, build & environment
构建、打包、签名、安装与卸载应用;查看设备和屏幕、执行 UI 操作、抓取 Trace、检查应用包与 native 库、拉取文件、检查和安装运行环境。需显式开启。Build, package, sign, install, and uninstall apps; inspect devices and screens, operate the UI, capture traces, inspect app packages and native libraries, pull files, and check or install the environment. Explicitly opt-in.
build_app · sign_app · install_app · capture_trace
长操作Long operations
构建、抓取和安装可能超出普通调用时限;在后台保留任务状态和 Evidence,可查询、取消并读取结果。Build, capture, and install can outlive a normal call; keep task state and evidence in the background, then inspect, cancel, or read results.
list_operations · cancel_operation · get_operation_evidence
会话与报告Session & report
转换并复用 Trace、声明分析边界、提交确定性校验、生成自包含 HTML 报告。Convert and reuse a trace, declare the analysis boundary, submit deterministic validation, and render a self-contained HTML report.
open_trace · begin_analysis · submit_analysis_result · render_report
证据与 bundleEvidence & bundles
列出或读取 Evidence;导出、导入和比较带 digest 的 bundle。List or read evidence; export, import, and compare digest-checked bundles.
list_evidence · get_evidence · export_bundle · import_bundle · compare_bundles
未知与 handoffUnknowns & handoff
记录、更新、列出和验证未知项;导出或恢复会话 handoff 快照。Record, update, list, and verify unknowns; snapshot or resume a session handoff.
record_unknown · update_unknown · snapshot_session · resume_session
报告内容Report contents
每次分析生成一份自包含的 report.html,离线可打开。旁边保留 findings、evidence、unknowns、validation 和 run 元数据,方便复查与归档。
Each run produces a self-contained report.html that opens offline, with findings, evidence, unknowns, validation, and run metadata kept alongside it for review and archiving.
- report.htmlself-contained
- findings.jsonclaims
- evidence.jsonproof
- unknowns.jsongaps
- validation.jsonchecks
- run.jsonmetadata
Agent + Diting,闭环完成一次分析。Agent + Diting: one closed loop.
描述问题,Agent 负责改代码、判断和决策;Diting 负责构建、签名、安装、启动、抓 Trace 和取证,最后生成报告。 Describe the problem. The agent edits code and decides what to do; Diting builds, signs, installs, launches, captures the trace, and gathers evidence before rendering the report.
对 Agent 说Say to the agent
分析这个应用冷启动慢的问题。先修改代码,构建、签名并安装到设备,然后启动应用、抓取 HTrace,定位启动关键路径,并生成带证据的报告。 Analyze why this app is slow to cold start. Edit the code, build, sign, and install it on the device, launch the app, capture an HTrace, trace the startup critical path, and produce an evidence-backed report.
执行链Execution
-
01
Agent 修改并复现问题Agent edits and reproduces it
修改代码,确认目标场景。Edit the code and confirm the target scenario.
-
02
Diting 构建、签名、安装Diting builds, signs, installs
build_app → sign_app → install_app,必要时 package_app;然后启动应用。build_app → sign_app → install_app, package_app when needed, then launch.
-
03
Diting 抓 Trace,Agent 取证Diting captures; Agent gathers evidence
抓取 HTrace,按场景调用有界工具并返回 Evidence。Capture the HTrace and call bounded tools by scenario.
-
04
校验并生成报告Validate and render
确定性校验后输出 HTML 报告和完整证据。Run deterministic validation, then render the HTML report and evidence.