Add initial integration for --json=timings behing -Zsection-timings by Kobzol · Pull Request #15780 · rust-lang/cargo (original) (raw)
What does this PR try to resolve?
This PR adds initial support into Cargo for JSON timing sections, implemented in rustc in rust-lang/rust#142123. This allows Cargo to read frontend/codegen/linking time from rustc, and thus reporting slightly more detailed data in the cargo build --timings output.
The PR modifies Cargo to tell rustc to emit the section messages (--json=...,timings), and it adds the section timings data to the HTML table output and the JSON output. It does not yet integration different sections in the HTML unit chart (I want to do that as a follow-up).
Note that the JSON timings are currently only supported on the nightly compiler (they are not stabilized). The new behavior is thus gated behing an unstable Cargo flag (-Zsection-timings). When the flag is unused, the HTML table should look more or less the same as before, just that the code now supports both options.
How to test and review this PR?
You can run e.g. this to generate the timing report with a nightly compiler:
export RUSTC=rustup +nightly which rustc
target/debug/cargo build -Zsection-timings --timings
on some crate, e.g. ripgrep.
Tracking issue: #15817