News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Profiling with CodeBlocks

Started by JohnCell, June 21, 2023, 05:00:50 PM

Previous topic - Next topic

JohnCell

Hello guys !

I'd like to know if it's possible to use CodeBlocks (or any add-on ) for code profiling under Windows ?
I've not been able to find any tutorial.

Thanks,
John

stahta01

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

nenin

Quote from: stahta01 on June 21, 2023, 06:27:46 PM
No idea if it still works.
Last time I tried there were solid problems, but I suppose related to fresh mingw versions, not C::B.

SashaGT

Hello! I hope this isn't too late to help!

I just tested it out on one of my projects. Here are the steps I took to get it working:


  • [Optional] Make a build target for profiling (Project > Properties > Build Targets).

  • Add the -pg compiler to the build target. (I believe you'll also want -g too..)

  • Compile the build target.

  • Run the application. This'll create a gmon.out file in the executable's directory.

  • Quit the application

  • Run the profiler through Code::Blocks (Plugins > Code Profiler).

Code::Blocks uses gprof for profiling. You won't get nicely drawn call graphs but you could also try and using gprof more directly:

I'm currently using C::B version 20.03-r11983