From 0c783920ab0a1bb433c7149419d6fd31d96dd904 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 8 Jun 2015 10:15:37 -0600 Subject: [PATCH] Add notes on templight for compile time perf --- 07-Considering_Performance.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/07-Considering_Performance.md b/07-Considering_Performance.md index 7dcf212..b7368f2 100644 --- a/07-Considering_Performance.md +++ b/07-Considering_Performance.md @@ -39,17 +39,24 @@ Templates are not free to instantiate. Instantiating many templates, or template For more examples see [this article](http://blog2.emptycrate.com/content/template-code-bloat-revisited-smaller-makeshared). -## Firewall Frequently Changing Header Files + +### Analyze the Build + +The tool [Templight](https://github.com/mikael-s-persson/templight) can be used to analyze the build time of your project. It takes some effort to get built, but once you do, it's a drop in replacement for clang++. + +After you build using Templight, you will need to analyze the results. The [templight-tools](https://github.com/mikael-s-persson/templight-tools) project provides various methods. (Author's Note: I suggest using the callgrind converter and visualizing the results with kcachegrind). + +### Firewall Frequently Changing Header Files -### Don't Unnecessarily Include Headers +#### Don't Unnecessarily Include Headers The compiler has to do something with each include directive it sees. Even if it stops as soon as it seems the `#ifndef` include guard, it still had to open the file and begin processing it. [include-what-you-use](https://code.google.com/p/include-what-you-use) is a tool that can help you identify which headers you need. -### Reduce the load on the preprocessor +#### Reduce the load on the preprocessor This is a general form of "Firewall Frequently Changing Header Files" and "Don't Unnecessarily Include Headers." Tools like BOOST_PP can be very helpful, but they also put a huge burden on the preprocessor.