[CMake] cmake script profiler

Bill Hoffman bill.hoffman at kitware.com
Tue Apr 23 16:24:09 EDT 2013


On 4/23/2013 3:50 PM, Volo Zyko wrote:
> 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?

That's funny.  I was just playing around with adding a profile option. 
My approach was to sum up all the time spent in each function.  It does 
not have a call stack but, should give you an idea of where it is 
spending the bulk of the time.   I suppose you could post process the 
output of a trace with your change, but that would be more work.

An example of my output on the ParaView project:

4.881 export
4.97701 vtk_wrap_python
5.15999 vtk_module_export
5.45701 VTK_WRAP_ClientServer
5.817 QT4_GET_MOC_FLAGS
6.159 vtk_module_impl
6.38601 pv_pre_wrap_vtk_mod_cs
7.08994 if
7.23499 vtk_add_python_wrapping
7.46001 QT4_WRAP_CPP
7.71494 configure_file
8.59399 vtk_module_config
8.904 pv_process_plugins
8.987 vtk_add_cs_wrapping
9.64503 set
11.654 try_compile
12.748 vtk_module_third_party
17.007 vtk_module_library
37.773 _vtk_module_config_recurse
112.788 include
158.092 add_subdirectory

Also, thinking of adding some stats to number of times a variable is set 
and how many variables are used.

-Bill




More information about the CMake mailing list