I'm searching for tool that helps calculate compilation time using CMake. Target project builds a lot of files, so I need to craft some "table" per each module. For example, project consists of 2 files - main.cc and libs.cc I need to calculate build time for libs and main differently.
I'm trying to set wrapper for g++, but in make -j4 it has some "race condition". Strings with Building status and building time are crossing.
.......
[ 3%] Building CXX object irohad/simulator/CMakeFiles/block_creator_common.dir/block_creator_common.o
0.12 1.42
[ 4%] Building CXX object schema/CMakeFiles/yac_grpc.dir/yac.grpc.pb.o
0.13 1.36
0.10 0.71
.......
Set new "Compiler" - wrapper for g++
#!/bin/bash
{ /usr/bin/time -f "%S\t%U" g++ "$@"; } 2> >(cat <(echo "g++ $@") - | cat)
and then
cmake -H. -Bbuild -DCMAKE_CXX_COMPILER=/path/to/script.sh
make | tee -a buildResults.txt
Please try adding following lines in the cmake, to measure time you can compile with single cpu and then run in parallel mode
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_COMMAND} -E time")
set_property(TARGET <your target> PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_COMMAND} -E time")
replace per your project name.
Hope this helps.
you can try this
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_COMMAND} -E time") set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${CMAKE_COMMAND} -E time")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With