0

Good day guys. I'm using bloodshed devc++ as ide which, I believe, is using mingw as compiler. I've been reading up lots of articles talking about optimization of code and bottlenecks which makes me want to try their recommended techniques :)). So the questions are:

  1. How do I measure how efficiently or how poorly my code is running?
  2. How do I know which parts of my code are the 'bottlenecks' (am I using the term right?)

thanks!

user571099
  • 1,491
  • 6
  • 24
  • 42

3 Answers3

2

You can use a profiler. As you are using MinGW compiler, use gprof.

Saurabh Manchanda
  • 1,115
  • 1
  • 9
  • 21
1

You can use a profiler in order to see what portions of your code are taking most time.

It's harder to say if your code is overall efficient or not. Try and compare its completion time with similar applications. You should define what performance you need and try to optimize your code in order to be below your threshold.

peoro
  • 25,562
  • 20
  • 98
  • 150
  • thanks for the reply. is that a separate program or is that part of the devc++ package? – user571099 Jan 29 '11 at 14:01
  • @user571099: I don't know if dev-c++ ships a profiler, anyway you can find plenty profilers out there (as separated programs): see [this post](http://stackoverflow.com/questions/4394606/beyond-stack-sampling-c-profilers) for example – peoro Jan 29 '11 at 14:03
  • 1
    If your code would compile ok on other systems and you have access to one, a Linux box with `oprofile` might give better results. `gprof` is minimally usable, but due to the insertion of extra profiling code into your code, it can easily make tiny functions that are normally fast without profiling look like bottlenecks once the profiling overhead is added. `oprofile` avoids this kind of observation interference by just sampling the instruction pointer. Unfortunately, I don't know any equivalent profiling tool for Windows. – R.. GitHub STOP HELPING ICE Jan 29 '11 at 15:02
0

Have you tried gprof for ming ?

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440