clang-build-profiler is a CLI tool that analyzes timings generated by clang++ -ftime-trace and generates a human-readable report, summarizing which parts of the build took the longest.
-
Build your project using
clang++with-ftime-traceflag enabled -
Point the CLI tool at the CMake build directory and select its desired output:
- Open the generated report:
- Available output formats include:
--output |
Description | Requirements |
|---|---|---|
mkdocs |
Nicest output for viewing, it uses MkDocs Material to serve an interactive GUI in browser | pip install mkdocs-material |
html |
Stand-alone HTML report, not as fancy, but doesn't require MkDocs | None |
terminal |
Colored in-terminal output, useful for small projects or with high level of pruning | None |
json |
JSON dump of profiling data, useful for custom analysis pipelines | None |
text |
Text file output, useful for saving human-readable build artifacts with profiling data | None |
- Builds a tree of includes and their parse timings
- Builds a tree of template instantiations and their timings
- Summarizes the information above into a digestible format
- Prettifies standard templates and their expansion (e.g.
std::basic_string<char, ...>➜std::string) - Automatically analyzes CMake builds with multiple targets
The project website serves as its main form of documentation.
The docs can also be viewed directly from GitHub:
- Getting started
- Configuration file
- Supported CLI flags
- Building the project locally
- Technical limitations
A shorter built-in documentation can be accessed with clang-build-profiler --help.
In many cases, build times can be noticeably improved through a relatively minor reorganization. To make this feasible, however, one would need a proper tool capable of profiling the build process.
clang++ -ftime-trace introduced in version 9.0 provides a perfect backend for such a tool, it generates traces in the Chrome tracing format, which can be even opened directly using Chrome about:tracing. However, raw traces are quite cumbersome to analyze in respect to the things that we actually care about, so I implemented a tool to summarize the key information.
The source code of this project embeds several dependencies:
| Library | Version | License | Used for |
|---|---|---|---|
| UTL | v8.3.3 | MIT | Formatting |
| fmt | v12.1.0 | MIT | Formatting & terminal IO |
| glaze | v6.0.0 | MIT | JSON parsing & serialization |
| argparse | v3.2 | MIT | CLI argument parsing |
| fkYAML | v0.4.2 | MIT | YAML parsing |
| Boost.Regex | v7.0.1 | Boost | Regular expressions |
| cmrc | #952ffdd | MIT | Embedding resources |
- Possibly a native GUI output with
--output=gui - Refinements in template prettification
- Tests on larger codebases
- A better selection of summaries
- Performance improvements
This project is licensed under the MIT License - see the LICENSE.md for details.



