ninjatracing README

The project's README from github.com/nico/ninjatracing. As one markdown file: README.md.

ninjatracing

Convert .ninja_log files to chrome's about:tracing format.

To view traces, either open about:tracing in chrome, or use https://www.speedscope.app/ or https://ui.perfetto.dev/.

Idea from Nick Carter, initial implementation from Richard Smith.

$ ./ninjatracing
Converts one (or several) .ninja_log files into chrome's about:tracing format

Usage:
    ninja -C $BUILDDIR
    ninjatracing $BUILDDIR/.ninja_log > trace.json

By default this will show build timing results for the most recent (possibly
incremental) build. To show build timing results for every target, whether
built in the last build or previously, use --showall. Note that this will
overlap multiple builds and will thus exaggerate build parallelism.

(When using --showall, ideally rm $BUILDDIR/.ninja_log and do a clean build.
If you don't have time for a clean build, at least run
`ninja -C $BUILDDIR -t recompact` first to remove no-longer-built targets.)

The results can be converted from .json format to .html format, for easier
loading into about:tracing, using trace2html from:
https://github.com/catapult-project/catapult/blob/master/tracing/bin/trace2html

ninjatracing (nico/ninjatracing)

Searching Database…

这是什么?ninjatracing 把 Ninja 构建系统生成的 .ninja_log 构建日志文件转换成 Chrome 的 about:tracing JSON 格式,这样你就能以时间线的形式直观查看每个构建步骤花了多长时间。
这是 GUI 应用,还是我在终端里运行的脚本?它是一个单文件的小型命令行脚本,不是库也不是 GUI 应用——你把它指向一个 Ninja 构建目录,它就把 JSON 打印到标准输出。
怎么生成和查看追踪记录?先用 Ninja 构建你的项目,然后运行 'ninja -C $BUILDDIR; ninjatracing $BUILDDIR/.ninja_log > trace.json',并在 Chrome 的 about:tracing 中打开生成的 JSON 文件(或用 trace2html 转换)。
除了 Ninja,我还需要别的东西吗?你需要一个基于 Ninja 的构建,让 .ninja_log 文件存在,另外还需要 Chrome 的 about:tracing 查看器(或 trace2html 工具)来实际查看输出。
使用 --showall 标志会发生什么?--showall 会显示曾经构建过的每个目标的时间,而不仅仅是最近一次构建,这会把多次构建叠加在一起,夸大构建实际呈现出的并行程度。
Chrome 的 about:tracing 查看器是什么?它是 Chrome 内置的时间线/追踪查看器,最初为分析浏览器本身的性能而构建,ninjatracing 的 JSON 输出与之直接兼容。
trace2html 有什么用?trace2html 是一个单独的工具,把 .json 追踪文件转换成独立的 .html 文件,这样你无需打开 chrome://tracing 也能查看时间线。
Creator
nico
Size
0.1 MB
Stars
530
Updated
CommitJan 31
Age
12y
Commits · 90 Days