Author Topic: Profiling with CodeBlocks  (Read 3475 times)

Offline JohnCell

  • Single posting newcomer
  • *
  • Posts: 3
Profiling with CodeBlocks
« on: June 21, 2023, 05:00:50 pm »
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

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7594
    • My Best Post
Re: Profiling with CodeBlocks
« Reply #1 on: June 21, 2023, 06:27:46 pm »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline nenin

  • Almost regular
  • **
  • Posts: 213
Re: Profiling with CodeBlocks
« Reply #2 on: June 22, 2023, 08:05:55 am »
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.

Offline SashaGT

  • Single posting newcomer
  • *
  • Posts: 7
Re: Profiling with CodeBlocks
« Reply #3 on: June 30, 2023, 07:41:20 am »
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