[CMake] cmake script profiler

Volo Zyko volo.zyko at gmail.com
Tue Apr 23 15:50:38 EDT 2013


Hi all,

We have a rather big project and use cmake for building it. At some point
our cmake scripts became very slow (around 4 minutes for single cmake run).
We are thinking now how to speed up it. Searching the web and this list
didn't give any results. It looks like there is no such thing as profiler
for cmake scripts. Am I right?

What about adding such capability to cmake? It looks like cmake's trace
provides enough info for time profiling, the only thing that it lacks is a
time stamp. Below is a small patch that adds time stamp and nesting level
(to simplify building a stack trace) to each trace line. Would it be
possible to integrate this change to the main line or are there better
options for time profiling of cmake?

diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 25ccbc7..0e6725c 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -361,6 +361,8 @@ bool cmMakefile::GetBacktrace(cmListFileBacktrace&
backtrace) const
 void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff)
 {
   cmOStringStream msg;
+  msg << "(" << std::fixed << cmSystemTools::GetTime();
+  msg << ") (" << this->CallStack.size() << ") ";
   msg << lff.FilePath << "(" << lff.Line << "):  ";
   msg << lff.Name << "(";
   for(std::vector<cmListFileArgument>::const_iterator i =
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130423/881b181b/attachment.htm>


More information about the CMake mailing list