Profiler settings in CMakeLists.txt

Hi All,

Does anyone have suggestions for adding -pg flags to the CMakeLists.txt file so that one could enable profiling--hopefully in a cross-platform manner?

I seem to recall that one has to add to the compiler flags and the linker flags; but, having studied the CMakeLists.txt file, I am quite confused.

Thanks
Eric

Does anyone have suggestions for adding -pg flags to the CMakeLists.txt file so that one could enable profiling–hopefully in a cross-platform manner?

Because I see you have an “@mac.com” address, I’ll assume you have a Mac. :wink: In this case, I’d suggest compiling a regular Debug build and running Shark, which does sampling – profiling for a certain period of time, then an interactive display of the results. You don’t need to add profiling flags. (Heck, you could run it on a release build, but without debugging symbols, it might not help much.)

To enable profiling with gprof, you want to change the CMAKE_CXX_FLAGS, either in your CMakeCache.txt or when you run cmake (-DCMAKE_CXX_FLAGS=‘-pg…’)

Hope that helps,
-Geoff

28.10.2010, 17:52, “Eric Brown” eric.c.brown@mac.com:

Hi All,

    Does anyone have suggestions for adding -pg flags to the CMakeLists.txt file so that one could enable profiling--hopefully in a cross-platform manner?

Why do you need it in CMakeLists.txt? Use custom CXXFLAGS instead
BTW, gprof is not the only or the best of existing profilers


Regards,
Konstantin

On Oct 28, 2010, at 8:59 AM, Geoffrey Hutchison wrote:

Does anyone have suggestions for adding -pg flags to the CMakeLists.txt file so that one could enable profiling–hopefully in a cross-platform manner?

Because I see you have an “@mac.com” address, I’ll assume you have a Mac. :wink: In this case, I’d suggest compiling a regular Debug build and running Shark, which does sampling – profiling for a certain period of time, then an interactive display of the results. You don’t need to add profiling flags. (Heck, you could run it on a release build, but without debugging symbols, it might not help much.)

To enable profiling with gprof, you want to change the CMAKE_CXX_FLAGS, either in your CMakeCache.txt or when you run cmake (-DCMAKE_CXX_FLAGS=‘-pg…’)

Hope that helps,
-Geoff

Jeez, tough crowd! :-/

I thought that I saw a significant difference in performance between Debian and Mac. I was hoping to use ratios from gprof to gain more insight.

Thanks for the tips,
Eric

28.10.2010, 19:20, “Eric Brown” eric.c.brown@mac.com:

On Oct 28, 2010, at 8:59 AM, Geoffrey Hutchison wrote:

     Does anyone have suggestions for adding -pg flags to the CMakeLists.txt file so that one could enable profiling--hopefully in a cross-platform manner?

Because I see you have an “@mac.com” address, I’ll assume you have a Mac. :wink: In this case, I’d suggest compiling a regular Debug build and running Shark, which does sampling – profiling for a certain period of time, then an interactive display of the results. You don’t need to add profiling flags. (Heck, you could run it on a release build, but without debugging symbols, it might not help much.)

To enable profiling with gprof, you want to change the CMAKE_CXX_FLAGS, either in your CMakeCache.txt or when you run cmake (-DCMAKE_CXX_FLAGS=‘-pg…’)

Hope that helps,
-Geoff

Jeez, tough crowd! :-/

I thought that I saw a significant difference in performance between Debian and Mac. I was hoping to use ratios from gprof to gain more insight.

You can also consider Valgrind’s Callgrind and Massif. For Linux you can use Intel V-Tune for free


Regards,
Konstantin

On Oct 28, 2010, at 11:20 AM, Eric Brown wrote:

On Oct 28, 2010, at 8:59 AM, Geoffrey Hutchison wrote:

Does anyone have suggestions for adding -pg flags to the CMakeLists.txt file so that one could enable profiling–hopefully in a cross-platform manner?

Because I see you have an “@mac.com” address, I’ll assume you have a Mac. :wink: In this case, I’d suggest compiling a regular Debug build and running Shark, which does sampling – profiling for a certain period of time, then an interactive display of the results. You don’t need to add profiling flags. (Heck, you could run it on a release build, but without debugging symbols, it might not help much.)

To enable profiling with gprof, you want to change the CMAKE_CXX_FLAGS, either in your CMakeCache.txt or when you run cmake (-DCMAKE_CXX_FLAGS=‘-pg…’)

Hope that helps,
-Geoff

Jeez, tough crowd! :-/

I thought that I saw a significant difference in performance between Debian and Mac. I was hoping to use ratios from gprof to gain more insight.

I think setting CXX flags would generally be the way to go. We could possibly add a build type if there is demand, but I much prefer the alternative tools already mentioned in this thread (both the Linux and Mac tools). I have used valgrind/callgrind quite a bit.

Marcus

I think setting CXX flags would generally be the way to go. We could possibly add a build type if there is demand, but I much prefer the alternative tools already mentioned in this thread (both the Linux and Mac tools). I have used valgrind/callgrind quite a bit.

Marcus

Hi Konstantin, Geoff, and Marcus,

valgrind did what I needed.  I had used it for memory leaks before, but not for profiling.  Thanks Geoff, for reminding me of Shark. It is the most convenient on my Mac.

Have a great weekend,
Eric

On Fri, Oct 29, 2010 at 7:26 PM, Eric Brown eric.c.brown@mac.com wrote:

I think setting CXX flags would generally be the way to go. We could possibly add a build type if there is demand, but I much prefer the alternative tools already mentioned in this thread (both the Linux and Mac tools). I have used valgrind/callgrind quite a bit.

Marcus

Hi Konstantin, Geoff, and Marcus,

   valgrind did what I needed.  I had used it for memory leaks before, but not for profiling.  Thanks Geoff, for reminding me of Shark. It is the most convenient on my Mac.

I am hoping to get Valgrind dashboard submissions up and running for
Open Babel and Avogadro soon. Avogadro really doesn’t have enough
tests for it to be all that useful yet though… Glad it did what you
needed, Geoff introduced me to shark, and it is a nice tool that is
very easy to use.

Have a great weekend too.

Marcus