You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-3Lines changed: 38 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -297,11 +297,11 @@ Run the CI and follow the output. Note: the option `continue-on-error: True` can
297
297
Consider using the action with `limit-access-to-actor: true`, to limit access to your account.
298
298
299
299
300
-
## Profile C++ compile time
300
+
## Profile C++ compile time of a translation unit
301
301
302
302
When doing heavy template meta-programming in C++ it can be useful to analyze what part of the code is taking a long time to compile.
303
303
304
-
[clang](https://clang.llvm.org) allows to profile the compilation time. To activate this function, add the `-ftime-trace` option while building.
304
+
[clang](https://clang.llvm.org) allows to profile the compilation time of a translation unit. To activate this function, add the `-ftime-trace` option while building.
305
305
306
306
In a CMake project, you can do this with the following command line:
307
307
@@ -317,7 +317,7 @@ find . -iname "*.json"
317
317
318
318
Then, you can open the file with the [Chromium tracing tool](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool/). Open the `about:tracing` URL in Chromium and load the .json. You will have the following display:
319
319
320
-

320
+

321
321
322
322
### Note for GNU/Linux users
323
323
@@ -329,6 +329,41 @@ Then, when running CMake **for the first time** use the following command:
329
329
CC=clang CXX=clang++ cmake ..
330
330
```
331
331
332
+
333
+
## Profile C++ compile time of a CMake target
334
+
335
+
When building a CMake target, it's interesting to profile which translation unit took most of the compile time.
336
+
337
+
Ninja and [ninjatracing](https://github.com/nico/ninjatracing) allow to do visualize the whole target build time.
338
+
339
+
First clone [ninjatracing](https://github.com/nico/ninjatracing) somewhere.
340
+
341
+
Then configure your CMake build to use Ninja. Run the following command in a **NEW** build directory:
342
+
343
+
```bash
344
+
cmake .. -GNinja
345
+
```
346
+
347
+
Now, build your project with Ninja:
348
+
349
+
```bash
350
+
ninja
351
+
```
352
+
353
+
The `.ninja_log` file should had been created in the build directory.
354
+
You can convert it to a file compatible with the [Chromium tracing tool](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool/).
355
+
356
+
Run the following command:
357
+
358
+
```bash
359
+
path/to/ninjatracing .ninja_log > trace.json
360
+
```
361
+
362
+
Now, you can visualize it with the [Chromium tracing tool](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool/). Open the `about:tracing` URL in Chromium and load the .json. You will have the following display:
363
+
364
+

365
+
366
+
332
367
## Launch a process on a particular CPU/CORE/PU
333
368
334
369
[hwloc tools](https://www.open-mpi.org/projects/hwloc/) allow to study computer and computer cluster topology.
0 commit comments