What is the Gradle --profile HTML report and how do you generate one?
answer
- --profile flag
- build/reports/profile/profile-*.html
- offline, no plugin
- config / dep-resolution / task-execution sections
- timestamped per run
basics
~10 sPass --profile to a build (e.g. ./gradlew build --profile). Gradle writes a self-contained HTML report to build/reports/profile/profile-<timestamp>.html showing where build time was spent.
solid answer
~40 sThe `--profile` command-line flag tells Gradle to instrument the build and emit an offline HTML report at `build/reports/profile/profile-<yyyy-MM-dd-HH-mm-ss>.html`. It requires no plugin, no network, and no account — it is built into Gradle. The report breaks total wall-clock time into phases: **Configuration** (per-project configuration time), **Dependency Resolution** (per-configuration resolve time), and **Task Execution** (per-task time, sorted slowest-first). A 'Summary' tab shows overall timings. You run it like `./gradlew assemble --profile`; each invocation produces a new timestamped file so you can compare runs. It is the simplest first step when a build feels slow and you can't or don't want to use a Build Scan.
code
bash · 3 lines./gradlew build --profile
# Report written to:
# build/reports/profile/profile-2026-06-30-09-12-44.htmlgo deeper
Know the flag, the output path, and that it splits time into configuration/dependency-resolution/task-execution.
Explain it's offline and plugin-free, why each run is timestamped, and that you read Summary first then drill in.
Position --profile vs Build Scans (offline/coarse vs networked/rich) and stress running warm/repeated builds for valid numbers.
Frame it as the zero-dependency baseline diagnostic suitable for restricted environments and CI artifact capture before standardizing on richer tooling.
## What `--profile` is `--profile` is a built-in Gradle command-line option that records timing data while a build runs and, at the end, writes a **self-contained HTML report** to: ``` <rootProject>/build/reports/profile/profile-<timestamp>.html ``` The timestamp (`yyyy-MM-dd-HH-mm-ss`) means every run produces a distinct file, so you can keep a history and diff runs by eye. The report is fully **offline** — no plugin, no Gradle account, no network call, unlike a Build Scan. That makes it safe for air-gapped or corporate environments. ## What it measures Gradle executes a build in phases, and the report mirrors them with tabs/sections: - **Summary** — total build time and a high-level breakdown. - **Configuration** — time spent *configuring* each project (running the build script bodies, registering tasks). High numbers here point at expensive configuration logic and are a classic argument for the **configuration cache**. - **Dependency Resolution** — time to resolve each `Configuration` (e.g. `compileClasspath`, `runtimeClasspath`). Spikes mean slow repositories, metadata downloads, or huge graphs. - **Task Execution** — every task that ran, with its duration, sorted slowest-first, plus its outcome (executed, `UP-TO-DATE`, `FROM-CACHE`, `NO-SOURCE`). ## How to generate and read it ```bash ./gradlew build --profile # -> build/reports/profile/profile-2026-06-30-09-12-44.html ``` Open the file in a browser. Start at **Summary** to see which phase dominates, then drill into that phase's section. Because the report is wall-clock based, run a **clean, warm-daemon** build for representative numbers, and run it more than once — the first run pays for compilation and downloads. ## When to reach for it `--profile` is the zero-setup, offline answer to 'why is my build slow?'. It's coarser than a Build Scan (no per-goal timeline, no cache-hit deep dive) but needs nothing installed and leaves an artifact you can attach to a ticket.
- Where exactly is the report written?Under the root project's build dir: build/reports/profile/profile-<timestamp>.html, one new file per invocation.
- Does --profile need a plugin or network access?No. It is built into Gradle and produces a fully offline, self-contained HTML file — unlike a Build Scan.
saying these in an interview costs you the question
- Claiming you need to apply a plugin or sign in to use --profile
- Confusing the offline profile report with a (network-published) Build Scan